Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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>


ŷ = <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!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!