Hey guys… I’ve been working in javascript, so I’m completely new to C#. I have a straight-up Noob question about C# and enums.
I’m trying to decipher the sample mouselook.cs script, so that I can cut it up and make it work for a networked game. here’s what’s confusing me, and how I’m interpreting it:
first we declare some variables, apparently:
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
so now we’ve got an enum with 3 values called RotationAxes. that seccond line is confusing. it looks like it’s creating a SECOND variable called axes, which is of type “RotationAxes” – so an enum as well… but it’s only grabbing one value – MouseXAndY – 0. so why not use an int?
so in my head, we’ve got 2 varaibles. one is an enumerator with 3 values, and one is… an enumerator?? with one value? a duplicate of RotationAxes, but with only one of it’s values? crazy.
now down below, we’ve got a bunch of conditional if statements, asking for different values of ‘axes’:
void Update ()
{
if (axes == RotationAxes.MouseXAndY){
{
.
.
.
else if (axes == RotationAxes.MouseX){
.
.
.
else{
see – in my head, that’s impossible. It seems that axes was given a specific value, and it’s not being changed anywhere else in the script… so how exactly is anything but the first conditional statement ever being called?
I’m sure there’s some sort of process that i completely don’t know about.
Anyone care to enlighten me?
Many thanks.