#### Archived

This topic is now archived and is closed to further replies.

# How do I get particles to fall?

This topic is 6005 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m trying to get a gravity effect with my particle system, but I''m just not sure how to go about it. Do I use a parabolic equation? Do i just set a gravity variable that increases over time and subtract that from the particles height? I would like to use the fastest method possible.

##### Share on other sites
increase the velocity in the direction of the gravitys pull.

##### Share on other sites
Track the velocity of the particle. Each frame, add a (constant) appropriate downward vector to the velocity (ie. appropriate to the scales you are using). The downward velocity will thus increase over time and the particle will behave nicely.

Done properly, things like parabolic trajectory will happen automatically and you don''t need to compute them as such.

##### Share on other sites
There are 3 vector quantities you have to consider for each particle. Position, Velocity and Acceleration.

If there are no other forces but gravity acting on the particle then acceleration will be

Vector a(0.0f, -9.8f, 0.0f);

When you initialize your particle engine you need to position the particle

Vector p(10.0f, 20.0f, 30.0f);

and give it a velocity

Vector v(10.0f, 20.0f, 0.0f);

here are some simple functions that model constant acceleration:

s = ut + 1/2a(t^2)
v = u + at
v^2 = u^2 + 2as

where

s = displacement
u = initial velocity
v = final velocity
t = time
a = acceleration

After some time has passed. ie you''ve moved on to the next frame you can calc a new position and speed.

using s = ut + 1/2a(t^2)

(vector)newPos = (vector)p * (scalar)t + 1/2 * (vector)a * (scalar)t * (scalar)t;

and using v = u + at

(vector)newVel = (vector)v + (vector)a * (scalar)t;

So now you''ve calculated a new position and a new velocity.

p = newPos;
v = newVel;

keep doing that over time and your particles will fly around realistically.

##### Share on other sites
If you limit the number of times this action happens per second, say it happens once per frame, 30 frames per second, then your downward velocity would be += (9.8/30).
You can be sure then that every frame, you particle moves downward at the fraction of the required.

Good eh

Unifex

1. 1
Rutin
19
2. 2
3. 3
JoeJ
15
4. 4
5. 5

• 22
• 19
• 11
• 13
• 17
• ### Forum Statistics

• Total Topics
631698
• Total Posts
3001768
×