How do I call ClampMagnitude?

I want to clamp a Vector3 called selfVelocity to a double maxSpeed.

I’ve tried:




But nothing seems to work. Sorry if this is a dumb question.

I think you are simply not assigning the result of the expression.

selfVelocity = Vector3.ClampMagnitude(selfVelocity,maxSpeed);

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).