is it possible to disable a character controller? I have a gameobejct I want to behave likea character sometimes and like a normal object at other times. is that even possible?
qJake
2
Get an instance of your CharacterController from another script and disable it.
// C#
CharacterController cc = GetComponent(typeof(CharacterController)) as CharacterController;
cc.enabled = false; // Turn off the component
//C Sharp
CharacterController control
void Update()
{
control.enabled=false;
}
Must be in Update
The controller must be disabled in the Update function in order for it to disable correctly.
You can do this by creating a flag “IsDead”. Then in your Update block, have an if statement checking every frame to see if the controller should be disabled.
if(isDead)
{
CharacterController cc = GetComponent<CharacterController>();
cc.enabled = false;
}