- Home /
limit of speed for rigidbody
Hi guys I'm working on pinball game... here is the link link text (As you can see) I have problem with ball acceleration in this game. Is there any way to limit rigidbody acceleration with script? Regards.
Try
if (rigidbody.velocity.z > maxSpeed){ rigidbody.velocity.z = maxSpeed; }
Answer by aldonaletto · May 13, 2012 at 09:27 PM
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.
@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.
Your answer
Follow this Question
Related Questions
Physics object slides while turning. 1 Answer
Sine-wave acceleration problem 1 Answer
Formula for acceleration to reach max velocity 1 Answer
Linear Acceleration in unity 3d? 4 Answers
Overcome drag 1 Answer