Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the Bullet 3D physics engine in a iOS application running openGL ES 1.1

Currently I'm accepting info from the gyroscope to allow the user to "look around" a 3d world that follows a bouncing ball (note: it only takes in the yaw to look around 360 degrees). Im also accepting information from the accelerometer based on the tilt to push the ball. As of right now, to move forward, the user tilts the devise forward (using the accelerometer); to move to the right, the user tilts the devise to the right and so on. The forward vector is currently along it's local Z-axis.

The problem is that I want to change the ball bounce based on where the user has changed the view. If I change the view, the ball bounces in the fixed direction.

I want to change the forward facing direction so that when a user changes the view (say to the look at the right of the world, the user rotates the device), tilting the devise forward will result in a forward force in that direction.

Basically, I want the forward vector to take the rotation into consideration.

Sorry if I didn't explain the issue well enough, its kind of confusing to write down.

share|improve this question
up vote 0 down vote accepted

Figured out the answer for anyone who gets the same issue.

If you get your RigidBody's btTransform and then multiply it by your force btVector3 and subtract the RigidBody origin from that, the return will be your force relative to your object's orientation. Now just apply this as a centeralForce/Impulse and it goes in the new direction.

share|improve this answer
Don't multiply with the full btTransform, only multiply with it's 3x3 orientation matrix member btTransform::getBasis(), then you don't need to subtract the origin afterwards. – Maik Semder Nov 13 '12 at 19:10
Btw. you can accept the answer if it works for you :) – Maik Semder Nov 13 '12 at 19:12

Your Answer


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.