- Home /
Change standart FirstPersonController variables via other script
Hello Guys,
im using the standart FPS controller script. I would like to disable the MouseX and MouseY axis but not able to find the correct reference in the C# code. All the other inputs should still be active. The charecter have to be able to move but not to look around with the mouse. Right now i an disabeling the whole script. Im writing Javascript.
what am i doing right now
FPSController.GetComponent("FirstPersonController").enabled = false;
what i would like to do (pseudocode)
FPSController.GetComponent("FirstPersonController") GetComponentMouseX = 0 | GetComponentMouseY = 0;
Greetings BP
The FPS Controller prefab has a $$anonymous$$ouseLook script, which is what you are after.
Thank you for the answer, alreade searched alot for the solution and always people were talking about the $$anonymous$$ouseLook script. In my Unity5 FPSController is no such thing as a $$anonymous$$ouseLook script. Only the FirstPersonController script with one dropdown part called $$anonymous$$ouseLook inside. So you are saying me to disable the part of the script FirstPersonController called $$anonymous$$ouseLook?
Answer by rajavamsidhar_gvs · Oct 16, 2015 at 11:00 AM
Attach this script to ur first person. click 1 one for off the controls click 2 for on the mouse controls..
using UnityEngine;
using System.Collections;
public class MouseControls : MonoBehaviour{
void Update(){
if(Input.GetKey(KeyCode.Alpha1))
this.gameObject.GetComponent<MouseLook>().enabled=false;//disabling mouse inputs when u click 1
if(Input.GetKey(KeyCode.Alpha2))
this.gameObject.GetComponent<MouseLook>().enabled=true;//enabling mouse inputs when u click 2
}
}
Hello and thank you for the reply. Sadly im recieving the following error message. "$$anonymous$$ouseControls.cs(8,54): error CS0246: The type or namespace name `$$anonymous$$ouseLook' could not be found. Are you missing a using directive or an assembly reference?" There is just no "$$anonymous$$ouseLook" script in my FPS controller. The standart assets are importet.
it is saying it dont have the mouselook.cs. tell me first how many scripts are there to firstperson.and what are they.then i'll modify my answer..
Your answer
Follow this Question
Related Questions
First Person Player 3 Answers
Object reference not set to an instance of an object. ( FirstPersonController) 1 Answer
No Y-Axis rotation FPS Controller 2 Answers
FPS Controller and crawling on Walls/Ceiling 0 Answers
Jittery FPS Camera when moving 3 Answers