#Character controller
1 messages · Page 1 of 1 (latest)
typo
we already made the function, now we just want to use it
public int Clamp(int value, int min, int max) {
if (value > max)
{
value = max;
}
else if (value < min)
{
value = min;
}
return value;
}
Code from earlier
it's value, min, max
yeah
and what do you do with that?
transform.eulerAngles.x = Clamp(angle.x, -90, 90);
well you'd set the angle.x itself, since that's what we're modifying
Note, the unity clamp function says:
Returns an undefined value if the minimum value is greater than the maximum value.
So it won't throw an error if you get the min max the wrong way round, it will simply stop working
We've all been in the exact same spot when learning something new
probably nan right?
there we go!
I'll probably forget some of this ngl
though, you might want to mod (make it wrap around) your y angle by 360
wdym
just angle.y = angle.y % 360
wait what does that do
Remainder of division
it makes it wrap around to 0 when it reaches 360
think of it like a remainder, or like the hands of a clock
Wouldn't that give a fraction from 0-1 though?
yeah
how to do what?
nevermind I have