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 am new to game development and I was trying to build a turret model, and control it through lua script in shiva3d. I can rotate it around the y axis which is no problem, but when it comes to pitching, I am not sure how to do that in a way which is independent of the Y rotation, for example,

in the default position, rotating with a positive value around X aims upwards, which is what I expect.

when I rotate it by 180 degrees around Y, the positive rotation around X aims downwards towards the ground instead of upwards.

on the other hand, if I rotate by 90 degrees, the turret rotates around it self as if its rolling...

I am not sure what to look for in order to understand how rotation in a 3d world should happen, so any pointers on that would be much appreciated

share|improve this question

It sounds like you're doing the rotations in the wrong order. The pitch rotation should be applied first, then the yaw rotation. That way, the turret is always in "default position" when pitch is applied, so the pitch rotation will do the right thing. Then you apply the yaw rotation to get it pointing the right horizontal direction.

share|improve this answer

A good pneumonic when performing 3D matrix operations is ISROT. This gives you the order of operations to follow when working with matrices.

Identity Scale Rotation Orbit Translation

share|improve this answer
You may have meant "mnemonic". :) – Anko Feb 18 '13 at 23:29

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.