Character demo movement is incorrect

Post Reply
jeff
Posts: 6
Joined: Thu Aug 02, 2012 12:40 am

Character demo movement is incorrect

Post by jeff » Thu Aug 02, 2012 12:57 am

When turning in the character demo, the ghost object seems to turn one way, while the camera turns the other. Instead, the ghost object should be "locked" to the camera, so that the same side is always visible. Also, if you press "W" to enable wireframe, you'll notice that the forward/backward movement direction does not correspond to the direction of the red/green/blue axis.

Negating the x component of forwardDir in CharacterDemo::clientMoveAndDisplay() and the x component of backward in CharacterDemo::updateCamera() appears to fix the issue. The ghost object will remain "locked" to the camera, and will properly move forward and backward along one of its axis.

Any ideas as to what the cause of this issue is (and a way to fix it that doesn't seem like a hack)?

Code: Select all

forwardDir.normalize ();
upDir.normalize ();
strafeDir.normalize ();
forwardDir.setX(-forwardDir.x()); // <-- add this

Code: Select all

//look at the vehicle
characterWorldTrans = m_ghostObject->getWorldTransform();
btVector3 up = characterWorldTrans.getBasis()[1];
btVector3 backward = -characterWorldTrans.getBasis()[2];
up.normalize ();
backward.normalize ();
backward.setX(-backward.x()); // <-- add this

Post Reply