(SOLVED) Disable First Person Character movment and STILL be able to controll the First PErson Camera.

So I had an Idea for a game. (Please don’t steal my idea!)
What if when you can see, you can’t move, but when you can move, you can’t see?

My problem is, I have a script that activates/deactivate the “First Person Controller” script. But then that means you can’t move your camera.

var scriptToControl : UnityStandardAssets.Characters.FirstPerson.FirstPersonController;
 
 function Start () {
      scriptToControl = GetComponent("FirstPersonController");
 }
 
 function Update() {
     if (Input.GetKeyDown(KeyCode.X)) {
           Debug.Log("User pressed X");
           if (scriptToControl.enabled)
                    scriptToControl.enabled = false;
                    ;
           
           else
                    scriptToControl.enabled = true;
                    
      }
}

I tried adding a “Mouse Look” script to my camera, but then the First Person Controller doesn’t move right.

Then I tried making it change the Walking Speed.

var scriptToControl : UnityStandardAssets.Characters.FirstPerson.FirstPersonController;
 
 function Start () {
      scriptToControl = GetComponent("FirstPersonController");
 }
 
 function Update() {
     if (Input.GetKeyDown(KeyCode.X)) {
           Debug.Log("User pressed X");
           if (scriptToControl.enabled)
                    scriptToControl.m_WalkSpeed = 0;
                    ;
           
           else
                    scriptToControl.m_WalkSpeed = 5;
                    
      }
}

But then i got this error:

“BCE0120: ‘UnityStandardAssets.Characters.FirstPerson.FirstPersonController.m_WalkSpeed’ is inaccessible due to its protection level.”

What do I do?

You can’t access m_WalkSpeed, because it is a private variable. You could change it in the “FirstPersonController.cs”. But I think there are better solutions than just changing this variable. You could add a variable public bool CanMove=true;and whenever you want to stop the player movement, set this variable to false. Also you have to change the controllers code a bit. Search for the “Update” function and change it like this:

private void Update(){
	RotateView();
	if(!CanMove){
		return;
	}
	//[existant stuff]
	
}

This way only the rotation-part of the controller will be done, if it should not move.

I HAVE FOUND A SOLUTION!
(In case anyone else wants to do the same idea as me)

I just used the old Character Controller Prefab. Since it has a SEPARATE script for moving the camera, I can disable the “Character Motor” script, and still move my camera.