Disable a script from another script (150784)

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.

So when you add the camera to the scene, the memory leak disappears? (I have this problem too).

You need to post this bug to the issue tracker, I think. I would vote for it

3 Answers

3

This should fix it:

Player.GetComponent.<CharacterMotor>().enabled = false;
Player.GetComponent.<SmoothMouseLook>().enabled = false;

No, he says that he always has a camera, but in the normal mode (without argument "headless") app works OK, without any memory leak (as I understood).

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 SmoothMouseLook? 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 SmoothMouseLook script and i want to disable it but the code line you gived to me was C#

That's write I find the solution : private var firstPersonControllerCamera; function start () { firstPersonControllerCamera = gameObject.Find("First Person Controller").GetComponent("SmoothMouseLook"); }

That’s write I find the solution :
private var firstPersonControllerCamera;
function start () {
firstPersonControllerCamera = gameObject.Find(“First Person Controller”).GetComponent(“SmoothMouseLook”);
}