edited March 23 in ORK Scripting
As the title says, Gil, in ork 2, is it possible to add and remove the interaction controller via script to an object? I can see the Interaction Controller component when I click on the Add Component on a game object, but just can't seem to add/remove it from a script.
Post edited by Nightsky on
  • The InteractionController component is just a regular component that you can add to a game object like any other. However, you also need to register it with ORK (which happens automatically when handling this via ORK's settings).

    So, this code will add the component and register it:
    ORK.Control.InteractionController = player.AddComponent<InteractionController>();
    player being a game object (should usually be the player).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited March 23
    Hm when I do that, it says the type or namespace "InteractionController" could not be found. I am on ork 2.26.1. I didn't want to upgrade because I am done with my game and I am going to release it soon. I don't want to upgrade it and get unforeseen bugs.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using ORKFramework;

    public class AddRemoveInteractionController : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {
    ORK.Control.InteractionController = this.gameObject.AddComponent<InteractionController>();

    }

    // Update is called once per frame
    void Update()
    {


    }
    }
    Post edited by Nightsky on
  • ORK components are usually in the ORKFramework.Behaviours namespace, so you need to add that as well. Your used IDE (most likely Visual Studio) should be able to give you a solution like adding that namespace when you hover over an issue :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited March 23
    Thanks, that was it! Oh yeah, I have a problem regarding it. When my interaction controller collider is on an object, the "inspect" hud will show up and I can interact with it using a key. The only problem is that if the interacton controller is still on it, but if I remove the interaction controller component and add it back briefly, the "inspect" hud will be gone and I can no longer interact with it until I move the interaction controller collider out of the object and back on it. I can no longer interact using the key I assigned in ork, but I can still interact if I left click the mouse. Is this a bug?

    The reason why I am doing this because I found that in my version of ork, let's say I put the interact key to "space". If I keep spamming "space" when I play the game, for some reason, sometimes that will break all interaction events and I can no longer interact with objects that has the interact event interaction unless I quit the game and come back, or I remove the interaction controller component itself and add it back.
    Post edited by Nightsky on
  • Interaction controller knows about interactions within it's trigger if something enters the trigger, so I assume Unity doesn't fire those trigger enter events in that case.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.