[Solved]rotating btKinematicCharacterController

Shockeye
Posts: 10
Joined: Sat Feb 07, 2009 10:48 am

[Solved]rotating btKinematicCharacterController

Post by Shockeye »

How do I rotate a btKinematicCharacterController? In the demo the controls move the object forwards, backwards, left right. I have a camera attached to a btKinematicCharacterController and I want turn left and right, so the view will turn rather than strafe.

btKinematicCharacterController::setWalkDirection(btVector3) seems to be the only way of controlling the object.

I've tried following the demo which uses something like this:

Code: Select all

m_character->setWalkDirection(walkDirection*walkSpeed);
But I can't seem to get btVector3::rotate(btVector3 wAxis,btScalar Angle) to work on walkDirection.

What approach would be best for this?
Last edited by Shockeye on Tue Feb 10, 2009 11:04 am, edited 1 time in total.
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: rotating btKinematicCharacterController

Post by pico »

Hi,

do you really need to rotate the characters volume in your application? For our games we never rotate the collision volume (which is usually just a simple box). You won't notice the difference. Just rotate the visible character but not the the collision volume. This avoids many problems such like not being able to rotate when being stuck on an edge that would not allow to rotate your volume.
Shockeye
Posts: 10
Joined: Sat Feb 07, 2009 10:48 am

Re: rotating btKinematicCharacterController

Post by Shockeye »

Sorry If I explained myself poorly. I don't really want rotate the volume. I need to rotate the direction of movement.
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: rotating btKinematicCharacterController

Post by pico »

The demo doesn't work like this. You need to modify it. You must not write to walkdirection directly but just set an walk angle.

float angle=...any degree..;
walkDirection=btVector3(0,0,1);
walkDirection.rotate(btVector3(0,1,0),angle);

"angle" should now be set according to your control scheme. For instance you can use the Y rotation of your Camera to set the angle.
Or use the cursor cursor to inc/dec the angle value.
Shockeye
Posts: 10
Joined: Sat Feb 07, 2009 10:48 am

Re: rotating btKinematicCharacterController

Post by Shockeye »

I can't seem to get btVector3.rotate to work.

I do this:

Code: Select all

btVector3 testRotate(0,0,1);
btScalar testAngle(15.0f);
testRotate.rotate(btVector3(0,1,0),testAngle);
and the value of testRotate stays the same.

I imagine I'm doing something stupid thats causing this, but I can't work it out.

Well, for the moment I'm going to try and rotate the vector in Ogre3d and then convert it to a btVector, although that's a little inefficient I guess.

Thanks for your help
Shockeye
Posts: 10
Joined: Sat Feb 07, 2009 10:48 am

Re: rotating btKinematicCharacterController

Post by Shockeye »

I am as dumb as a box of hammers
I didn't realise btVector3.rotate returns the rotated vector rather than rotating the original :oops: