Jump to content
  • Advertisement
Sign in to follow this  
mmurphy

Calculating and applying forces

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on the way forces are used in my physics engine and was hoping possible someone could comment if this was general idea (it seems to be from what I gathered from other physics engine/docs)

[color="#000000"][font="Arial"]Apply Gravity to total forces[/font]
[color="#000000"]
[color="#000000"][font="Arial"]Calculate Collisions (using total force + velocity for detecting collision)[/font]
[color="#000000"][font="Arial"]- If there is a friction, add the friction force to total force[/font]
[color="#000000"][font="Arial"]- If there is resting, subtract out the gravity from total force[/font]
[color="#000000"]
[color="#000000"][font="Arial"]Calculate acceleration as “acceleration = total force/mass”[/font]
[color="#000000"][font="Arial"]Calculate velocity as “velocity += acceleration * dt[/font]
[color="#000000"][font="Arial"]Calculate new position as “new position = current position + velocity”[/font]
[color="#000000"]
[color="#000000"][font="Arial"]Set total forces to zero, set acceleration to zero.

Edit: corrected my acceleration formula
[/font]

Share this post


Link to post
Share on other sites
Advertisement
You almost got it. The below scheme is simpe, effective and widely used. It's called the symplectic Euler integration algorithm.

calculate forces

acceleration = force / mass
velocity += acceleration * dt
position += velocity * dt

reset forces and start all over

Share this post


Link to post
Share on other sites

I think you want acceleration to be calculated using total force/mass, but apart from that everything else looks fine.


Ah yes, that is what I meant.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!