Issue of control with kinematic object

gautam
Posts: 8
Joined: Sun Dec 10, 2006 5:14 am

Issue of control with kinematic object

Post by gautam »

Hi,

I am setting a body to be kinematic object and trying to set its motion. But I am not able to make it move at all. This is the code I have to try and make it move

Code: Select all

void GameObject::Update()
{
	if(m_Body->isKinematicObject())
	{
		btVector3 translate(5.0f, 0.0f, 0.0f);
		m_Body->translate(translate);
	}
	
	float m[16];
	btDefaultMotionState *state = static_cast<btDefaultMotionState *>(m_Body->getMotionState());
	state->m_graphicsWorldTrans.getOpenGLMatrix(m);
	m_Model->SetTransform(m);				
}
I would like to know if I am doing something wrong here with the Kinematic object because it seems to have no effect on the object.

Thanks
Gautam
gautam
Posts: 8
Joined: Sun Dec 10, 2006 5:14 am

Post by gautam »

Hi

Thanks I got this working. Apparently I was under the impression that motion state gets set internally but that isn;t the case.
gautam
Posts: 8
Joined: Sun Dec 10, 2006 5:14 am

Post by gautam »

Hi,

Now I am having a few more issues with the kinematic objects. I was under the impression that although the kinematic object can be user controlled I should be able to still collide with other objects - static or dynamic. However the object seems to just pass through. Am I wrong in thinking that in case of kinematic objects the physics will take care of collision.

Thanks
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Post by Dragonlord »

Yes and no. Collisions are still done on kinematic objects but like dynamic ones they can fall asleep ( and collisions on two sleeping bodies are not monitored ). Hence moving them around doesn't wake them up.

body1->setActivationState(DISABLE_DEACTIVATION);

takes care of this ( at last it did for me :D )
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

It's best to disable sleeping during motion of kinematic objects indeed.
You can see an example of kinematic objects in CcdPhysicsDemo, if you enable the #define at the top of the demo.

Let me know if there are still have problems,
Erwin