Whenever there is an interaction or dialogue, my player character will keep moving in the direction they were moving in once the interaction event starts. I read this might be solvable via the wrapper components, but I'm not exactly sure where to add it into the controller script. Does the onDisable function need to encompass my entire script or just a part added onto the end?
  • You just have to add an OnDisable function to your control component's script. You can also write a small wrapper script with the function to work in-between ORK and your control component, e.g. if you're using a 3rd party product you can't (or don't want to) change.

    See the Unity documentation on the OnDisable function.
    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!
  • using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using InControl;

    namespace CMF
    {
    //Advanced walker controller script;
    //This controller is used as a basis for other controller types ('SidescrollerController');
    //Custom movement input can be implemented by creating a new script that inherits 'AdvancedWalkerController' and overriding the 'CalculateMovementDirection' function;
    public class AdvancedWalkerController : Controller {

    void OnDisable()
    {
    // called when the control is blocked
    }

    void OnEnable()
    {
    // called when the control is unblocked
    }


    Like this? Sorry I'm just not sure exactly how to integrate it into my custom script. I'm assuming I put something in these enable/disable brackets?
  • Yes, that's correct - you put what you need to do between the brackets of the OnDisable function (and OnEnable if you also need to do something when the control is enabled again).
    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!
  • I'm sorry but what's an example of something I could put in the brackets to cancel out the momentum or velocity? I tried the movement speed but it seems the speed isn't what makes it keep moving after the disable
  • Well, that depends on how your control actually moves the game object, e.g. using a character controller, you'd use something like this:
    controller.Move(Vector3.zero);
    Or to set the velocity of a rigidbody:
    rigidbody.velocity = Vector3.zero;

    The actual code also depends on how the different variables/fields in the script are named.
    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!
  • Got it working thank you :)
Sign In or Register to comment.