- Home /
Rigidbody Add Force
The docs says to use AddForce in fixed update to apply force over time. Basically what I would like is to simulate a gust of wind when the player presses the jump button. So theoretically something like
rigidbody.Addforce(transform.up*500);
Should work. Why doesn't it? my character just stands there.
Answer by aldonaletto · Jan 06, 2012 at 11:06 AM
When you apply a force, it causes an acceleration equal to force/mass, which increases the velocity while the force is being applied - and that's probably the problem: if you apply the force during a single physics cycle (20mS) the velocity change will be very small - even worse if you have useGravity = true.
You have two alternatives to get a more predictable result:
1- Add the velocity directly:
rigidbody.velocity += transform.up * 10;
This is the easier alternative, since you don't have to worry about mass or gravity.
2- Use Impulse mode:
rigidbody.Addforce(transform.up * 10, ForceMode.Impulse);
In Impulse mode, Unity applies instantly the velocity change equivalent to the force applied during 1 second. Mass and gravity will be taken into account, thus the result is a little more complicated to predict.
Your answer
Follow this Question
Related Questions
Simple rigidbody.AddForce only applying once each time key is pressed 1 Answer
Is Add Force The Best Solution 1 Answer
Move object invertically to another 0 Answers
Have player fall down with platform? 0 Answers
Smooth dashing issues 0 Answers