|
You can use Vector3.ClampMagnitude in FixedUpdate:
var maxVel: float = 10.0; // max absolute velocity
function FixedUpdate(){
rigidbody.velocity = Vector3.ClampMagnitude(rigidbody.velocity, maxVel);
}
ClampMagnitude doesn't modify the direction, just clamps its magnitude to the value passed. Works perfect, thanks ;)
May 14 '12 at 11:38 AM
angelhard
@angelhard, please click the check mark under the voting thumbs - this will help other users with similar problems, and - if rules didn't change - also adds 2 points to your reputation.
May 14 '12 at 11:42 AM
aldonaletto
(comments are locked)
|

Try
if (rigidbody.velocity.z > maxSpeed){ rigidbody.velocity.z = maxSpeed; }