C# and stuff

Im learning to do my scripts in C# since i think i mastered doing them in javascript so, why not learn something new?

The problem is that there is a script showing me errors that i can’t decipher…

		if ( mCooldown < 0.0f )
		{
			Event event = new Event (Vector3.zero, Vector3.zero);
			
			mEvents.Add (event);
			
			mCooldown += DELTA;
		}

the 3rd and 5th lines shows me the ‘;’ expected error.

Any thoughts ?

Event is a class with a constructor with 2 vectors as parameters and mEvents is an ArrayList class.

Thanks

.ORG

C# is really picky about data types, so watch our for that in the future.

I think Event event = new Event (new Vector3.zero, new Vector3.zero); needs to be Event event = new Event (new Vector3.zero, new Vector3.zero);

That error is somewhat generic and generally means “hey, something is wrong somewhere”.

I would say make sure that mCooldown is a float and that all the functions you are calling there are taking the parameter types you think they are.

I figured out… or resolved at least!

the word “event” seems to be forbidden for use, like reserved for future use (or maybe it’s used already??). I changed the ‘event’ variable to ‘e’ and works perfectly now!!

Any expert can confirm this ? (not so-experts are welcomed to comment too :wink:)

.ORG

‘event’ (all lowercase) is C# keyword, so you can’t use it as a variable name.

That’s not the case here. Vector3.zero is a particular value. You only have to use new if you’re creating a new object, such as ‘new Vector3(x, y, z)’.

Thanks NCarter for your confirmation. The close to C# for me is Visual C++, so i’m learning a lot again!

.ORG