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

In my game you are controlling a person walking(X and Y) and they can:

Rotate view - -180 to +180
Move a direction - Forward, Backwards, Left, Right.

I want the Move to get closer to a goal position by using the Forward, Backward, Left and Right.

The player can be looking anywhere on the -180 to 180 rotation and the direction of the Forward, Backward, Left and Right is changed by Rotation.

share|improve this question

closed as not a real question by BlueRaja - Danny Pflughoeft, Trevor Powell, Josh Petrie, Byte56, Jimmy Feb 4 '13 at 18:28

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

What is your question? – Trevor Powell Jan 31 '13 at 23:50 ? – Tetrad Feb 1 '13 at 0:08

So your problem is: You have 4 different directions (vectors) and you want to make a linear combination of them, to reach some point "x". Observation 1: You can make that in 2D using only 2 directions (vectors), (for math people: marix rank is 2).

So first, choose 2 linearly independent vectors (Forward - (1,0), Right - (0,1)) and rotate them with your rotation (multiply with rotation matrix).

Then, all you have to do is solve the system of 2 linear equations with 2 variables. You can probably write that in 1 line of code.

Another way is to rotate your point "x" with negative rotation, then you will get the solution straight away.

share|improve this answer
The point was that you can't control the rotation of the player only the movement. – user25810 Feb 1 '13 at 6:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.