I am trying to do my character grab and launch objects and enemies but to do it with enemies I need to turn off, and on again character controller, is there a way (js) ?
Thanks in advance!
I am trying to do my character grab and launch objects and enemies but to do it with enemies I need to turn off, and on again character controller, is there a way (js) ?
Thanks in advance!
function Update () {
if(Input.GetButtonDown(“Fire1”))
{
var myController : CharacterController = GetComponent(CharacterController);
Destroy(myController);
}
if(Input.GetButtonDown(“Fire2”))
{
gameObject.AddComponent(CharacterController);
}
}
The bast way to do this is in Character script if using unity CharacterMotor script
In CharacterMotor.js
Change
var canControl : boolean = true;
To
static var canControl : boolean = true;
Use
//turn character off
CharacterMotor.canControl = false;
//turn character on
CharacterMotor.canControl = ture;
same question