# Set input relative to map rotation?

## Set input relative to map rotation?

```I'm trying to figure out how I can make the input which looks like this :
// Checks if player is pressing movement keys, if is applies force to specified direction
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
{
}

if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
{
}

if (Input.GetKey(KeyCode.UpArrow) && groundCheck.isGrounded == false || Input.GetKey(KeyCode.W) && groundCheck.isGrounded == false || Input.GetKey(KeyCode.Space) && groundCheck.isGrounded == false)
{
groundCheck.isGrounded = false;
rigid.velocity = new Vector2(rigid.velocity.x, jumpPower);
}

Always move according to the maps rotation.
So, even if the map were to rotate the player doesn't get inverted inputs (player is children of map, so it rotates too) :
Right now A is always to left, according to the players position, but if the player would rotate 90 degrees the input would be wrong, Left would be up/down, but I want it to still be left.

Here's a picture example : (Sorry for the horrible painting, I blame mouse :> )

I do want the physics in the world to not change when I rotate the world.
So if the player is rotated 90 degrees it should fall to the side instead of down. :D
```

The key is knowing current world rotation, you need to maintain it as you rotate e.g.:

``````double worldRotation;

void rotateWorldLeft()
{
worldRotation = (worldRotation + 90) % 360;
}
``````

then, when moving the character, just Rotate the `Vector2`s along e.g.:

``````if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
{
}
``````

Alternatively, if you have only few and known in advance possible rotations, you could use lookup table coupled with enum and modulus:

``````Enum Direction { Up = 0, Left, Bottom, Right }

Vector2[] Directions = { Vector2.up, Vector2.left, -Vector2.up, Vector2.right };

Direction worldOrientation; /*again keep it up-to date*/
...
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
{