- Home /
Turn off CharacterControl Component Through Script?
I have seen this question once before, but their was no anser. so how would i script it to turn off the "Character Controller" Component because there is no check box so i cant disable it. i tried this
var player:Transform;
function Update() {
player.GetComponent(CharacterController).enabled = false; }
And this should work but it doesn't because there is no check box, I works on my other components that do have check boxes.
Answer by user-9668 (google) · May 07, 2011 at 03:17 PM
You need to make a boolean (true or false) to make a check box. Try this:
var player:Transform; var on : bool = true;
function Update() {
if(on){
player.GetComponent(CharacterController).enabled = true;
}else{
// what ever
}
}
Your answer
Follow this Question
Related Questions
Why is my gameObject.Find("Spotlight").GetComponent.() not working? 3 Answers
disable/enable Mouse Look(c#) with a script of js 7 Answers
How to enable/disable Javascript using a C# script? 1 Answer
enable and disable boxcollider (whats wrong with my script?) 2 Answers
How to use GetComponent? 2 Answers