Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a platform with btBoxShape as shape, and I want to rotate it every certain amount of time to simulate a rotating platform.

Right now I rotate it with Ogre (my rendering engine) and use a custom btMotionState to synchronize it with bullet. The thing is that when a player goes on top of it (a player is a btRigidBody with mass 1) the body should stay in the same coordinate relative to the platform and rotate with it. Right now it is kinda bugged and it doesn't rotate properly, and I don't know the exact cause.

What should I do to achieve this effect?

Here is a video with an example of what I want to do: http://youtu.be/z60jiGldX48?t=1m2s

share|improve this question

1 Answer 1

Add a boolean "on_ground" variable to keep track of if your player is standing, or in midair. Ray cast underneath the player just like you would to see if it is OK to jump.

If your player->on_ground is false, and the ray hits something to stand on, make this object your new "platform" and set player->on_ground to true. Save the local (not world) coordinate where the ray hit as your "platform_offset". You can get this by taking the world space position where the ray hit, and transforming it by the inverse of the platform's model matrix.

Otherwise, if player->on_ground is true, then you just transform the platform_offset by the platform's model matrix. Move the player with it artificially if the platform has moved.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.