having trouble starting out with C#

tring to make a variable I type it as
public int maxHealth = 100;
is this correct if not how should I be doing this?

1 Answer

1

If it’s located in a class, then yes, it’s correct.

(Easiest answer ever !)

ok in a class that works but what if I am declaring it outside before everything im tring to switch from java to c# is that possiable or so I need to declare these in start or declare what they are then set in start?

should it look like public int maxHealth; void start(){ maxHealth = 100; } or should it look like void Start(){ public int maxHealth = 100; }

nevermind looking around more at the code relized I had placed it to high thank you for the rapid response

That's one of the main differences you immediately notice between javascript/unityscript and C#, you always have to define a class to begin with. (But if you create a script from inside unity, it normally gives you the correct class to start out with.)