- Home /
Move Cube With Force and slow it down
I want to create an impulse force on an object and track its speed.
if (Input.GetKeyDown(KeyCode.UpArrow))
{
var relativeForce = new Vector3(0, 0,-100);
rigidbody.AddForce(relativeForce, ForceMode.Acceleration);
}
This Moves my cube forward but it moves and stops almost immediatly.
I want the velocity of the cube to have a bell curve effect. Ie: slowly starts increasing in speed to a maximum speed and then slows down to zero speed.
I have tried adding a frictional force to counteract the object movement but it seems to to get applied.
Did you try to play with the drag value for the rigidbody?
Answer by robertbu · Feb 15, 2013 at 05:00 PM
To get something that slowly increases speed, you will need to add a bit of force over a number of frames rather than a single force. Take a look at the Component/Physics/Constant Force component. You can turn it on and off. As for slowing, play with Rigidbody.drag.
I'm unsure of why your object slows to a stop almost immediately. Is there friction? Is it resting on a surface?
You are right. This works. I had a problem that was unrelated. I see now that drag works perfectly for what I had wanted.