- Home /
Simple angles question - How to get the position to the right of an object relative to their current direction?
I'm working on a top-down 2D game, so my characters are moved on the X and Y axes, and rotated on the Z axis. If my character is rotated to a certain direction on Z, what is the formula to get the position to that character's right? Really, all I'm looking to get is a single point that is 3 units to the right of the direction that my character is facing, i.e. would be adjacent to his right ear.
Answer by Olgo · Apr 15, 2015 at 07:34 PM
I've done something like this on one of my projects. I ended up using an empty gameobject that was a child of my player. I could move the empty gameobject relative to my player's position and then query its position in world space as well.
emptyGameObject.transform.localPosition; //local space
emptyGameObject.transform.position; //world space
Yeah, I was thinking of doing something like this. Was curious if there was a good solution that didn't require extra Gameobjects, but it's no big deal-- when it works, it works!
Your answer
Follow this Question
Related Questions
Need a little help with quick angle equation 2 Answers
Problem with Clamping Values for Object's Rotation 1 Answer
Bounce into the air 1 Answer
Rotate Object to Euler Angle using Physics? 3 Answers
Get angle relative to GameObject 1 Answer