The question is answered, right answer was accepted
Disable a script from another script
I searched everywhere and i never find an answer : I want to disable the character motor (It's right) and the MouseLook script (it's wrong)(it's called "SmoothMouseLook") and everytime I get the error following : "BCE0005: Unknow identifier: 'SmoothMouseLook'" How can I solve this ? here's my script :
var enterRP : boolean;
var enterWP : boolean;
var enter : boolean;
var enterPassword : boolean;
var Player : GameObject;
function OnTriggerEnter (other : Collider) {
if(other.gameObject.name == "Player"){
enter = true;
if(Input.GetKey(KeyCode.E)){
enterPassword = true;
Player.GetComponent(CharacterMotor).enabled = false;
Player.GetComponent(SmoothMouseLook).enabled = false;
}
}}
function OnTriggerExit (other : Collider) {
if(other.gameObject.name == "Player"){
enter = false;
}
}
function OnGUI(){
if(enter == true) {
GUI.Label (Rect(Screen.width / 2 - 150, Screen.height / 2 - 250, 150, 30), "[E] to enter password");
}
if(enterPassword == true){
// some other code line
}
}
I d'ont show all GUI code and the password codes but that are working so I just want help for disabling the character motor and the SmoothMouseLook script. Thanx.
Answer by Vylax · Oct 15, 2015 at 03:40 PM
That's write I find the solution : private var firstPersonControllerCamera; function start () { firstPersonControllerCamera = gameObject.Find("First Person Controller").GetComponent("SmoothMouseLook"); }
Answer by dkjunior · Oct 14, 2015 at 04:54 PM
This should fix it:
Player.GetComponent.<CharacterMotor>().enabled = false;
Player.GetComponent.<SmoothMouseLook>().enabled = false;
Answer by Vylax · Oct 14, 2015 at 06:37 PM
Now I get a new error : BCE0018: The name 'SmoothMouseLook' does not denote a valid type ('not found'). Did you mean 'UnityEngine.SendMessageOptions'? what can I do now ?
Do you have a script/component named Smooth$$anonymous$$ouseLook? From the code above I assumed you do.
(Also, as a side note, your response should've been a comment rather than a new answer.)
Yes I have the Smooth$$anonymous$$ouseLook script and i want to disable it but the code line you gived to me was C#
Follow this Question
Related Questions
Why doesn't enabling and disabling not work? 1 Answer
error CS1525: Unexpected symbol `' 2 Answers
How to disable any type of component? 2 Answers
How to change the order of things inside of a canvas? 1 Answer
BCE0044: expecting ''', found '\r'. 1 Answer