- Home /
Mathf.Clamp is 'Sticky'?
I have a camera parented to a pivot object that I control to rotate around it.
I've Mathf.Clmaped the values and it works well, but if I go to an extremity and get clamped and then attempt to change direction, there is a huge delay before the camera begins to rotate, making its boundaries feel 'sticky'
Any help is appreciated. Thanks! - YA
Answer by Owen-Reynolds · Aug 15, 2015 at 06:19 PM
No. Clamp is a 1-time thing, and isn't the tiniest bit "sticky." For example: in int x=Mathf.Clamp(x,1,10); x=x+y;
the second adding line y
doesn't know or care about the clamp, and will gladly take x
out of the 1-10 range.
Clamp is merely: if(x<min) x=min; else if(x>max) x=max;
. It doesn't do anything more than that.
When it seems like a 1-time operation is continually affecting an object, sometimes it's because you're accidentally running the line for many more frames than you intended. But it's never because you "queued-up" that line a few frames ago (unless you put it in a coroutine.)
Your answer
Follow this Question
Related Questions
How to Rotate camera around object SMOOTHLY when using Input.GetKeyDown 1 Answer
Mouse Orbit snapping issues 0 Answers
First Person Camera Rotation 360 degrees on all axis 0 Answers
Rotate an object around another on input 0 Answers
Reposition camera behind the player character during movement 1 Answer