# Splitting this into a x and y point?

This topic is 2776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Alright, so I'm still trying to make my players movements relative to the camera. I got a good answer here:http://stackoverflow.com/questions/4321382?tab=votes#tab-top
But he ends it with: s(Jx x̂ + Jy ŷ)

So how can I turn that equation into a x and y?

##### Share on other sites
Each of the terms, x̂ and ŷ is a vector, each therefore having its own x and y components. So, basically, you have:

x̂ = <a, b, 0.0>

and

ŷ = <c, d, 0.0>

Where a, b, c, and d are just values that came out of the vector math shown in the other formulas in that post. a and b are the world/game space x and y components of the axis, x̂, pointing to the camera's right. If the player moves a units in the x direction and b units in the y direction, the player will have moved towards the right side of the camera without moving closer or further away. Similarly, c and d represent the world/game space x and y components of the axis, ŷ, pointing away from the camera. So if the player moves c units in x and d units in y, then the player would move away from the camera.

So, if you expand out that final equation using the formulas I've listed above, and separate into bits that represent movement in the world/game space x and y directions, you will get:

player_translation.x = s*Jx*a + s*Jy*c;
player_translation.y = s*Jx*b + s*Jy*d;

Notice how the player_translation.x equation refers to a and b, which were the world/game space x direction components of the two projected camera axes. Similarly the .y version refers only to b and d, which represented the y direction components of the two vectors.

Hope that helps!

1. 1
2. 2
Rutin
21
3. 3
JoeJ
18
4. 4
5. 5

• 14
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631722
• Total Posts
3001892
×