Forces and Impulses Bullet Physics engine - reeseschultz/godex GitHub Wiki

⚠️ 🔥 DISCLAIMER 🔥 ⚠️

This is a work in progress feature that was published to give the possibility to early test it. Any feedback / bug report is welcome but keep in mind that this is subject to changes according to the received feedbacks.

The Physics Engine is used to simulate the Dynamics of a body, via Rigid Body. When doing this kind of simulation, it's a lot useful to impress forces to a body: You may want to push a bit the Character, animate a Ragdoll, grab a cup, code an explosion, 🎳, etc...

In all those situations you need to apply a Force, and in Godex Bullet Physics you can do it by adding one of the following components to a Rigid Body:

  • Force: When you add this component, an external amount of Energy is applied to the body until you remove it. You can set the force amount, the force direction relative to the body, the force location relative to the body.
  • Impulse: The impulse is similar to the force, but it applies the given energy all in one shot. When you add this component, the external energy is impressed and the component is removed.
  • Torque: When you just need to apply an angular force, you can use add this component. It will impress only an angular force until you remove it.
  • TorqueImpulse: Similar to the torque, but this component add a torque impulse, then the component is automatically removed.

💡 The four above components are batch components, this mean that each Rigid Body can have multiple Forces, Impulses, ..., .

Difference between Force and Impulse

Apart the above differences where the Impulse Component is removed after its application, while the Force Component keep applying the force until you remove it: in general, the Force and the Impulse are computed differently.

The force applies the given energy overtime, while the impulse applies the given energy immediately.

When you apply a central impulse of 10, that impulse is immediately applied to the velocity. Assuming the initial velocity is 0, apply an impulse of 10, makes the velocity reach immediately 10.

impulse = 10
velocity = 0
body_mass = 1

velocity += impulse / body_mass

# velocity = 10

While, apply a force of 10, makes the body reach the velocity of 10 after 1 second.

force = 10
velocity = 0
body_mass = 1

delta_time = 1/60

time = 0
loop {
    velocity += (force / body_mass) * delta_time

    time += delta_time
    print("time: " + time + " velocity " + velocity)
}

# time: 0.0166 velocity: 0.1666
# time: 0.25 velocity: 2.5
# time: 0.5 velocity: 5.0
# time: 0.75 velocity: 7.5
# time: 1.0 velocity: 10.0
# time: 1.5 velocity: 15.0
# time: 2.0 velocity: 20.0
....

If you want to know more about this topic, search for Force and Impulse it's a fun topic, here I can pass you a link: https://www.engineeringtoolbox.com/impulsive-forces-d_1376.html

➡️ Next chapter: Systems