Using MotionState with CharacterController

Post Reply
Kukanani
Posts: 25
Joined: Sat Feb 21, 2009 5:08 am

Using MotionState with CharacterController

Post by Kukanani »

Hi all,

I'm basically using code that is copy-pasted from CharacterDemo. How can I set a motionState for my character? Is there a way to find a rigid body that is associated with the character controller, or how else should I do this?

Thanks,
Kukanani
mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

Re: Using MotionState with CharacterController

Post by mickey »

Hi

You mean the ghost object? That's what the character controller uses.
Kukanani
Posts: 25
Joined: Sat Feb 21, 2009 5:08 am

Re: Using MotionState with CharacterController

Post by Kukanani »

Ah, thanks.

Kukanani
Kukanani
Posts: 25
Joined: Sat Feb 21, 2009 5:08 am

Re: Using MotionState with CharacterController

Post by Kukanani »

Hey, I hate to revive this dead thread, but this just isn't working for me.

I have an Ogre3D entity that I want to follow the orientation of my btGhostObject. btGhostObject has no setMotionState method, and it also has no btRigidBody, which is the only way to set a MotionState. How do I do this?

Thanks,
Kukanani
Sorlaize
Posts: 18
Joined: Sun Mar 29, 2009 5:00 pm

Re: Using MotionState with CharacterController

Post by Sorlaize »

Kukanani wrote:Hey, I hate to revive this dead thread, but this just isn't working for me.

I have an Ogre3D entity that I want to follow the orientation of my btGhostObject. btGhostObject has no setMotionState method, and it also has no btRigidBody, which is the only way to set a MotionState. How do I do this?

Thanks,
Kukanani
btGhostObject just checks for collisions using its shape, so it has a static rotation if I'm right?

btGhostObject and btRigidBody both derive from btCollisionObject, which has the methods getWorldTransform() and setWorldTransform(). You can set the position using m_ghostObject->getWorldTransform().setOrigin( btVector3(m_ogrePosition.X, m_ogrePosition.Y, m_ogrePosition.Z) ). You can get the position using m_ghostObject->getWorldTransform().getOrigin() which returns a btVector3.
User avatar
John McCutchan
Posts: 133
Joined: Wed Jul 27, 2005 1:05 pm
Location: Berkeley, CA
Contact:

Re: Using MotionState with CharacterController

Post by John McCutchan »

Hi,

btMotionState is currently only available for rigid bodies. You can always manually synchronize your graphics transformation with one obtained from the character controller.

As Sorlaize said, you can use getWorldTransform() to obtain the current transformation of the btGhostObject.

HTH,
John
Kukanani
Posts: 25
Joined: Sat Feb 21, 2009 5:08 am

Re: Using MotionState with CharacterController

Post by Kukanani »

Ah, thanks, that does it.

Kukanani
Post Reply