How would I increase a static value when a function happens)? Would it work like this:
static var Score = 5;
unction Update(){ //{function goes here (like a collision) }
Score += 1; }
How would I increase a static value when a function happens)? Would it work like this:
static var Score = 5;
unction Update(){ //{function goes here (like a collision) }
Score += 1; }
First, the update function calls every frame, so putting your code inside there for this wouldn’t work.
Simplest solution would just to use OnCollisionEnter() and stick “score = score+1” inside there.
You code should work fine.’
Ooops, EyeSix beat me to it
Score += 1;
That will certainly increase the value of score by one. This is an even better way:
Score++;
Now, where to put it? If you want score incremented every time a function happens, but the ++Score directly inside that function. Putting it inside Update() won’t work so well since that’s called every frame.
Edit EyeSix is faster at the draw. That’s what I get for stopping to open a diet mountain dew!