x


how I can slow down a Rigidbody little by little?

I have a cube...

I apply addforce to the cube:

AddRelativeforce(0,0,10)

how I can slow down the cube little by little?

more ▼

asked May 18, 2011 at 12:26 AM

hkikijugb55 gravatar image

hkikijugb55
19 3 2 7

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

As Joshua said the amount of drag will slow down the cube over time. You could also apply forces in the opposite direction of the rigidbody.

Sorry for this somewhat pseudo code as I cannot test it out at the moment.

currentVelocity = rigidbody.velocity;
oppositeForce = -currentVelocity;
rigidbody.AddRelativeForce(oppositeForce.x,oppositeForce.y,oppositeForce.z);
more ▼

answered May 18, 2011 at 01:06 AM

save gravatar image

save
9.8k 60 55 96

You probably want to multiply that opposite force by a small factor to slow down the rate of deceleration.

May 18, 2011 at 01:53 AM DaveA

Yes perhaps a Vector3.Lerp from 0 to -currentVelocity would do the trick.

May 18, 2011 at 10:12 PM save
(comments are locked)
10|3000 characters needed characters left

Increase the drag over time? Decrease the velocity of time?

more ▼

answered May 18, 2011 at 12:34 AM

Joshua gravatar image

Joshua
6.9k 47 48 104

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3214
x460
x52

asked: May 18, 2011 at 12:26 AM

Seen: 5498 times

Last Updated: May 18, 2011 at 10:12 PM