mcaden
28-08-2008 06:37:32
I've implemented my character movement like so:
With rtrans being my movement speed(-mMovespeed/2 for walking backwards).
This seems to work great except for one thing. Apparently my character is drunk. He doesn't move in a straight line. He'll veer to one side just slightly, then later veer slightly to another side.
The veering seems to be completely random. It'll veer to one side, I'll restart the app, and it'll veer to the other side over the same patch of ground. The ground is completely flat. The collision is a cube set to the same size as the ogre mesh's bounding box.
The problem seems to arise from trying to get gravity to work.
This causes gravity to work, but while active causes the veering issue explained above.
void Character::translate( Real rtrans)
{
Vector3 trans = mBody->getGlobalOrientationAsOgreQuaternion() * Vector3(0, 0, rTrans);
mBody->addForce(trans, NX_IMPULSE, true);
}
With rtrans being my movement speed(-mMovespeed/2 for walking backwards).
This seems to work great except for one thing. Apparently my character is drunk. He doesn't move in a straight line. He'll veer to one side just slightly, then later veer slightly to another side.
The veering seems to be completely random. It'll veer to one side, I'll restart the app, and it'll veer to the other side over the same patch of ground. The ground is completely flat. The collision is a cube set to the same size as the ogre mesh's bounding box.
The problem seems to arise from trying to get gravity to work.
mBody->addForce(NxVec3(0, -mBody->getMass() * 1.5, 0), NX_IMPULSE);
This causes gravity to work, but while active causes the veering issue explained above.