- Home /
Such thing as a smooth clamp?
What i mean by this is a clamp that doesnt just snap something back once its beyond the limit, i mean something that prevents it from going beyond the limit, period.
update: my clamp is transform.rotation = mathf.clamp (transform.position.x, -90, 90)
Answer by Eric5h5 · Dec 27, 2014 at 03:42 AM
You can't assign a float to transform.rotation, which is a quaternion. Anyway, the whole point of clamp is that the number can't go beyond the designated limit. There's never any "snapping back".
var foo = 10;
var foo = Mathf.Clamp (foo + 10, 0, 20);
In this example it's impossible for foo to be less than 0 or greater than 20.
The OP might be asking if it's possible to use a Clamp one time in Start, to permanently prevent a number from going out of range (no -- programs don't work that way.)
Or is doing a Clamp infrequently, letting the number escape the bounds a bit (just do it every frame.)
Your answer
Follow this Question
Related Questions
clamp rotation the other way? 1 Answer
my MainChara shakes when the Mathf.Clamp stops it from going off screen 1 Answer
Camera rotating past clamp 0 Answers
Cant Clamp 1 Answer
How to clamp player to viewport constraints when rotating 1 Answer