Does anyone know how to calculate the x,y position behind a target using it's current Orientation/Rotation.
I'm not that great with math, yes even simple High School math like this.
I appreciate any/all help.
Does anyone know how to calculate the x,y position behind a target using it's current Orientation/Rotation.
I'm not that great with math, yes even simple High School math like this.
I appreciate any/all help.
Didn't test it, but this should work:
Code:float tmpX = Math.Cos(Unit.Facing + (Math.PI / 2)) * 3; float tmpY = Math.Sin(Unit.Facing + (Math.PI / 2)) * 3; int behindX = Unit.X - tempX; int behindY = Unit.Y - tempY;
That sort of works, it takes me to the left corner that's ALMOST behind it. I guess I need to figure out which direction the mob is facing to get directly behind it?
Thanks for the response![]()
A player's position + his facing gives you a 2 dimensional vector, that's all you need.
v = (target_x, target_y) + s * (cos(target_facing + pi/2), sin(target_facing + pi/2))
Now you can just set s to -1 if you want to behind the target, or an even smaller number to be further behind.
Might have ****ed up somewhere but that should give you an idea.
Meh I did indeed. You'll have to adjust it to WoWs coord. system:
so in wows system it should be: v = (target_x, target_y) + s * (cos(target_facing), sin(target_facing))Code:/\ x | <----|-----y
as it's system is rotated by pi/2 to the common coord. system.
Hope it's right now ~~ brb suicide
Last edited by SKU; 02-21-2009 at 12:22 PM.
That works great, thanks both of you for responding. I would give rep if I could.