I'm very new to Blender. I'd like to setup a very simple rigid body physics system using the game engine. The system is simply a pole hinged in the middle of a block, which can move horizontally on a plane with friction, and walls to prevent it flying off the plane. It responds to a horizontal force that acts on the block, at every frame/timestep.

enter image description here

It's well known in engineering as the 2D cart/pole problem, aka inverted pendulum, and the rigid body equations are well known, but in Blender we don't need them! A simulation would start with the pole upright, and then apply random forces/impulses, (actuate it), horizontally on the block. When the pole falls below horizontal, its physically impossible for it to get back to vertical, and the simulation can end.

Setting this up procedurally would be a really nice/helpful introduction to rigid bodies and actuators in the BGE. I think in terms of the BGE/Physics the only scripting needed is to use a random, applyForce(...) or applyImpulse(...), on the block at each frame/timestep.

I'm not really sure that the game engine is needed for this simulation, only physics, as there is no user interaction? The output is just the sequence of rendered images, for a small time step/frames per second, and the value of the actuator/force applied at each timestep/frame.

Perhaps a the easiest place to start is from the [domino's tutotrial][4]

The things I'm stick on are,

  1. How to hinge the rod to the block, I think I need a constraint, OR Maybe I should use a single armature bone ?
  2. To apply a random force or impulse at each keyframe, I think I need something like bpy.ops.anim.keyframe_insert ?

Trying to apply a force to a cube with BGE


1 Answer 1


I made a simple example in the game engine of a mouse controlled inverted pendulum. It answers only your question about the hinge, but maybe you can go from there.

The body block has a rigid body constraint, type hinge, target is the pole. The weight at the top is parented to the pole.

I'm sure it's not physically correct, but I had to change translation and rotation damping in the physics properties of the pole to have a chance at controlling the pendulum. I also reduced the mass of the pole.

If you'd like to have a look, here's the blend file:

  • $\begingroup$ Hi Sanne, thanks a bunch for your help !!! I'm trying to do the simulation in Bullet Physics right now, because that's a bit easier for me to understand, and get working. Your blend file was really helpful, and I'll try to use it when I have the simulations ready for rendering from Bullet Physics. Best, Aj $\endgroup$
    – Ajay T
    Jul 11, 2015 at 21:52
  • $\begingroup$ You're welcome, Ajay T, glad I could help a bit. Good luck with your project! $\endgroup$
    – Sanne
    Jul 12, 2015 at 2:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .