As @Malleck666 Mentioned, you need to use GetComponent on the actual script, you’re trying to use it on a property of a component instead of the component.
Unity inspector auto-capitalizes the first letter in pascal case, so you can’t go by inspector, especially when a custom inspector is used and thus completely custom names can be displayed instead.
You need to make better use of the auto-complete feature in your IDE (which I assume is Visual Studio). When you type that period before “mouseLook”, you would have gotten a list of exposed members that you can access, and typing “mouse” should have narrow the list down to only members with the word “mouse” in them, and thus would have given you the correct variable name to access. In this cause, that script has Mouse Look defined as “m_MouseLook”.
The first and second line throw the text editor errors visible,
The third and fourth line throw the same errors at runtime, mentioned in my original post.
I should also mention that I am trying to access the FirstPersonController script a component of FPSController, from a script on the FirstPersonCharacter GameObject. So I am calling the parent from the child:
Thank you for your advice, Invertex about the IDE. Also a good choice of username
MouseLook does not derive from Monobehaviour or Component. It is just a class. So you cannot use “GetComponent” on it.
Also, if you opened up the FirstPersonController script, you would see that the MouseLook property is “private”, so it cannot be accessed from outside. So your choices are:
Create a “MyFirstPersonController” script or something like that, and have it derive from “FirstPersonController”. That way you will have access to all the private members. You’ll assign that script as your controller instead.
Use Reflection to get a reference to the private variables you want. This is slightly more complex but it works too.
Just edit the FirstPersonController script, it’s just a .CS file. You can change the MouseLook m_MouseLooks variable to “public” so you can access it.