Counter issues, hitting -1?

Hello there all,

I’ve been having this problem with my counter, although I have wrote :

	if(units <=0)
	{
	units = 0;
	}
	if(units >=99)
	{
	units = 99;
	}

When manipulating it through code, it hits -1, then goes to 0. That quick hit is causing havock with my numbers, adding and extra unit where there should not be one.

Can someone give me a hand please?

Many thanks,

Keep it up guys!

There’s nothing in the code you posted that would cause any issues, but:

units = Mathf.Clamp (units, 0, 99);