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.