Kinematic physics objects not matching up with scene nodes

jonmiller

10-07-2008 13:46:51

More problems with my ship here. The way I have it set up currently is that I load my ship and attach it to a child node of the root. Then I create a child node of the ship and attach to it my collidable geometry (lets call this console for now). Then I create an NxActor and set it's position to the center of console's WorldAABB. On startup this works, everything draws in the correct place. However, when I start translating my ship the faster I it goes, the more the actor seems to drift behind. If I'm at full speed it's off by about 4 feet or so, and half speed about 2 feet.

The way I'm translating the ship is just calling a translate on the ship's scene node by passing a unit z vector multiplied by ship speed multiplied by the seconds since last frame. Each frame that I update the ship I update the console actor (it's kinematic) by calling moveGlobalPosition(consoleSceneNode->getAttachedObject("console")->getWorldAABB().getCenter());
I've tried everything from getting the scene node's position, it's AABB center, World AABB center. I've also tried changing the order of when i translate vs when I update the physics. I'm not sure what is going wrong here. I've moved the world->simulate() function call to before and after I update my entire scene, but nothing seemed to change either. This is pretty confusing and frustrating because I feel like it should work and I've tried everything I can think of. Any advice? I'd appreciate it.

jonmiller

14-07-2008 15:04:50

I seem to have fixed my problem. I'm not sure why it was doing what it was, but in any case there was a more correct way to do it. Originally I was moving around the ship and putting the collision boxes around it, but now I'm moving the collision boxes and drawing the ship in the correct place. Now I don't get any jitter and I can move around smoothly. I still can't figure out how to get it to stick to the floor when I'm not moving though. I've tried all kinds of friction and freezing position and none of it works.