CharacterController.Move called on inactive controller

So, I’m following a tutorial on a Diablo-esque game that is made in Unity 4. However, I am unable to make the enemy nor the player move with this piece of code. Furthermore, the error log states that the CharacterController.Move has been called on an inactive controller, even though it is right there in the inspector? Can someone help please? I checked the similar topics and no one has answered the similar issue.

Error Log:
CharacterController.Move called on inactive controller
UnityEngine.CharacterController:SimpleMove(Vector3)

public class Mob : MonoBehaviour {
    public CharacterController controller;

    void Update ()
    {
        chase ();
    }

    void chase()
    {
        transform.LookAt (player.position);
        controller.SimpleMove (transform.forward*speed);
    }
}

Then it may just be disabled (the little checkbox on every component). If you want to make sure it’s enabled
put

void OnEnable(){ //or Awake() or Start()
    controller.enabled = true;
}

in there

1 Like

I tried setting it to true, but even when I try and playtest it…Unity is adamant in considering it inactive.

Maybe it’s not the enemy, but the player with its controller? (if you click on the message in the console, it should highlight the corresponding GameObject)

Couldn’t be, the component is under the enemy. I tried also to disable the player controller, so that the character controller is just on the enemy, but no luck.

Do a Debug.Log(controller.enabled); to see what it returns. Maybe also check GameObject.activeSelf or activeInHierarchy

Where and how should I put the code for activeSelf and activeinHierarchy?

Assets/Scripts/Mob.cs(37,25): error CS0120: An object reference is required to access non-static member `UnityEngine.GameObject.activeSelf’

I placed the Debug.Log (controller.enabled); in the chase() function. It returns True there.
Now this is a huge contradictory mess of trues and falses from Unity. All I want to do is to make the enemy follow the player…

Debug.Log(controller.gameObject.active[self/InHierarchy])

I have been plagued with this problem and I accidentally just got a clue why this was happening in my application. Try going to the character controller and changing the “step offset” variable. Mine was .3 and I changed it to something bigger like .35. This uncovered the following error msg…

“Step Offset must be less or equal to + * 2”

Even if I reset it back to it’s original value of .3 I still got the error. Once I changed my step value to something that didn’t give me an error (in my case .1) my controller started working again. My suspicion is that a U4 step offset value was not compatible with U5 but no warning was generated to that effect after the upgrade.

10 Likes

Rob-Hafey, you are God sent. Thank you. step offset = .1 did the trick

Love U Thanks that works but on 0.22

I had the same issue, making the player bigger it’s been solved for people who still have this issue.

1 Like

Making Step Offset to 0.1 works …Thanks to Rob-Hafey

dragon_script’s advice worked for me (making the player bigger). In my case, I used a package from the asset store and when I dragged the player prefab onto the scene, it was tiny and therefore couldn’t move. It’s worth checking your prefab’s size after incorporating it in your scene.

I had this issue occur because I was disabling all my rigidbodies in the start method. The character controller is considered a rigidbody so if you have any code that disables it, it’ll cause this issue.

8 years later, and your protip is still useful :slight_smile: thanks @Rob-Hafey

1 Like

I came here because I was having a similar issue, but funilly enough, my Unity crashed and that somehow fixed the issue.

You can also just do the math. look at what you have your hight and radius set to in your “Character Controller” (Mine was set to 0 for both). Then add the height and the radius and multiply the solution by 2. The number you get is what you should set the step offset to. (Because my values were 0, I did 0 + 0 * 2 = 0. So I set my offset to 0 and it worked.

MERCI !!!