- Home /
How do I call ClampMagnitude?
I want to clamp a Vector3 called selfVelocity to a double maxSpeed.
I've tried:
Vector3.ClampMagnitude(selfVelocity,maxSpeed);
ClampMagnitude(selfVelocity,maxSpeed);
selfVelocity.ClampMagnitude(maxSpeed);
But nothing seems to work. Sorry if this is a dumb question.
Comment
Best Answer
Answer by Tarlius · Feb 27, 2013 at 07:10 AM
I think you are simply not assigning the result of the expression.
selfVelocity = Vector3.ClampMagnitude(selfVelocity,maxSpeed);
Answer by Eric5h5 · Feb 27, 2013 at 07:08 AM
As the docs say, ClampMagnitude returns a copy of the vector with its magnitude clamped. So you assign it to a variable (it could be assigned to the same variable that you pass in).
Your answer
Follow this Question
Related Questions
Clamping Vector3 2 Answers
How do I make an array of vectors? 1 Answer
Vector3 Clamp 3 Answers