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.

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. http://i.stack.imgur.com/OcDr1.png

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.

1  
What is your question? –  Trevor Powell Jan 31 '13 at 23:50
    
red3d.com/cwr/steer ? –  Tetrad Feb 1 '13 at 0:08
add comment

1 Answer 1

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
add comment

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