I was following a video by HyperShadeTutorials(007-HyperShadeTutorials - Unity 3D FPS -Mouselook Script (C Sharp) Part 2 of 3 - YouTube)
in which he teaches you how to create a mouselook script in C#, I have not yet finished it, however, there are multiple errors in the code, I have tried multiple ways to solve the problem to no avail. I wish to test the MouseX movement as he does in Part 2 of his series yet I simply am unable. Please help me, this is extremely fustrating
I would appreciate it if you could explain thoroughly on a solution and what causes the problem, I’m a beginner so any information would be useful to me.
Here is what I have written so far:
public class Look : MonoBehaviour {
public enum RotationAxis (MouseX = 1, MouseY = 2);
public RotationAxis RotXY = RotationAxis.MouseX | RotationAxis.MouseY;
//X Axis
//sensitivity
public float xspeed = 200f;
//Minimum camera angle
public float xmin = -360f;
//Maximum camera angle
public float xmax = 360f;
float RotationX = 0f;
//Y Axis
//sensitivity
public float yspeed = 200f;
//Minimum camera angle
public float ymin = -45f;
//Maximum camera angle
public float ymax = 45f;
float RotationY = 0f;
public Quaternion RotOrigin;
void Start () {
RotOrigin = transform.localRotation;
}
void Update () {
if (RotXY == RotationAxis.MouseX) {
RotationX += Input.GetAxis ("Mouse X") * xspeed * Time.deltaTime;
Quaternion Xquat = Quaternion.AngleAxis(RotationX, Vector3.up);
transform.localRotation = RotOrigin * Xquat;
}
}
}
Errors:
Look.cs(6,34): error cs1519: Unexpected symbol ‘(’ in class, strut or interface member declaration.
Look.cs(6,42): error cs1519: Unexpected symbol ‘=’ in class, strut or interface member declaration.
Look.cs(6,54): error cs1519: Unexpected symbol ‘=’ in class, strut or interface member declaration.
Note: I have changed the variable names as I prefer shorter ones(don’t know why, it’s just more aesthetically appealing to me)