I solved the problem myself, in the enum line I used the wrong type of brackets I used () instead of {}.
C# Mouselook Script errors, need assistance.
I was following a video by HyperShadeTutorials(https://www.youtube.com/watch?v=-LJsXN55TC4) 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)
Answer by gjf · Nov 12, 2015 at 03:44 PM
enums are not defined with () - use {} (curly brackets) instead ;)
Follow this Question
Related Questions
NullReferenceException on Invoke in another class 1 Answer
Time.deltatime not working. 1 Answer
error CS0201 1 Answer
Visual Studio 2015 keeps crashing... 1 Answer