Moving a Kinematic Object

User avatar
nikki
Posts: 22
Joined: Sat Jun 14, 2008 3:38 pm
Location: Doha, Qatar.

Moving a Kinematic Object

Post by nikki »

I've create a kinematic object, by creating a static rigid body, and doing this:-

Code: Select all

body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
body->setActivationState(DISABLE_DEACTIVATION);
However, when I try to move it around using translate or by just setting the transform, every frame, it doesn't move. It just stays in the same position.

Is there something else I need to do before being able to animate a kinematic object?

Thanks for your help! :)
voxel
Posts: 14
Joined: Fri Jul 04, 2008 2:23 pm

Re: Moving a Kinematic Object

Post by voxel »

nikki wrote:I've create a kinematic object, by creating a static rigid body
I think the correct way is to create the a dynamic rigid body then do this:

body->setSleepingThresholds (0.0, 0.0);
body->setAngularFactor (0.0);
// This line does not work well for my moving kinematic objects
// body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
User avatar
nikki
Posts: 22
Joined: Sat Jun 14, 2008 3:38 pm
Location: Doha, Qatar.

Re: Moving a Kinematic Object

Post by nikki »

Are you sure about that? I tried that just now, but the object is affected by other dynamics objects. What I want is a one way interaction actually: Kinematic object pushes dynamics objects around, but dynamics objects can't push kinematic objects around. They should also not be affected by gravity. Kind of like a moving platform or a life for example.
User avatar
nikki
Posts: 22
Joined: Sat Jun 14, 2008 3:38 pm
Location: Doha, Qatar.

Re: Moving a Kinematic Object

Post by nikki »

Ok, after some more investigation, I finally found the answer. It turned out that the setup was right, but the object had to be moved in a different way. Instead of the object itself, it should be moved through its motionState. This way of moving it works:-

Code: Select all

btTransform newTrans;
body->getMotionState()->getWorldTransform(newTrans);
newTrans.getOrigin() += btVector3(0,0.02,0);
body->getMotionState()->setWorldTransform(newTrans);
Maybe you should try it out too, voxel. :)
voxel
Posts: 14
Joined: Fri Jul 04, 2008 2:23 pm

Re: Moving a Kinematic Object

Post by voxel »

nikki wrote:

Code: Select all

btTransform newTrans;
body->getMotionState()->getWorldTransform(newTrans);
newTrans.getOrigin() += btVector3(0,0.02,0);
body->getMotionState()->setWorldTransform(newTrans);
Maybe you should try it out too, voxel. :)
Thanks. I was following the old CharacterController demo.

I actually don't mind my kinematic objects being affected by dynamics objects :)