Noob question: how do I apply a force to a cube?

kergoth

17-07-2010 10:04:45

This is clearly a noob question. I have tried my best to figure out the answer by myself, but none of my attempts succeeded. So, here it is: I've successfully compiled the wiki tutorial 2, with the cubes that fall when 'B' is pressed. This is great! I've actually wrapped the machinery inside a script language that is interfaced to C++, and allows me to create cubes from a command line, and spawn them in the world!

Now, I try to apply a force to these cubes to make them move. I've a OgreBulletDynamics::RigidBody created for each cube, and I've tried to use setLinearVelocity and applyForce on it, but nothing moves. I have the debugDrawer enabled, and I've checked the bounding boxes, they do not move either.

There is obviously some really silly thing that I'm doing, but after reading the code of the demos, I couldn't find out what it is...

Any idea? Perhaps adding a tutorial 3, where one can apply a force on a cube when a key is pressed would be a good idea?

Thanks a lot!

kergoth

18-07-2010 09:26:30

I found the problem, it was due to the activation state of the cube. By calling OgreBulletDynamics::RigidBody::enableActiveState(), I got it reacting to impulses!

Cheers,
KG