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 basic 2D camera:

transform =
   Matrix.CreateTranslation(-position.X, -position.Y, 0) *
   Matrix.CreateRotationZ(-rotation) * 
   Matrix.CreateScale(new Vector3(zoom, zoom, 1)) *
   Matrix.CreateTranslation(new Vector3(viewportWidth / 2f,
       viewportHeight / 2f, 0)); 

The camera tracks an entity in a top down view. The entity is moved using the keyboard commands.

  • Up key adds new Vector(0, -1)
  • Down key adds new Vector(0, 1)
  • Left key adds new Vector(-1, 0)
  • Right key adds new Vector(1, 0);

and the entity is drawn using spritebatch (initialised with the above camera matrix) with rotation 0.

The movement vectors make is seem like the entity is facing with negative Y being forward but the 0 rotation means the default way the entity is facing is down (positive Y).

Am I missing something with the movement having a direct translation to the keyboard directions and the rotation being opposite? The entity shoots bullets (with vector2(0,1) velocity) at 0 rotation and they are shooting out behind the entity. How would I solve this disconnect between the player action and the keyboard directions without adding 180 degrees to all rotation logic in the game.

share|improve this question
    
I had a problem similar to this, and it turned out I was on the wrong side of the entity :(... Took me a few hours of frustration before I figured that one out. –  UnderscoreZero Apr 12 '13 at 22:40
    
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.