Jump to content
Posted 12 January 2013 - 03:05 AM
Posted 12 January 2013 - 03:45 AM
Are these actually position vectors, I mean vectors representing positions of shooter and target? Or do you mean that vectorA is the direction of the shooter and vectorB is a vector from the shooter's position to the target? I'm assuming the second case, because direction of the shooter must be known to make the decision of turning either left or right. In that case, I would use cross product. If cross product of vectorA and vectorB is less than 0, it's on one side and if greater than 0, it's on the other side. See http://www.gamedev.net/topic/289972-cross-product-of-2d-vectors/
Posted 12 January 2013 - 03:50 AM
if your talking about a 2D world, and all objects are axis-aligned(with y being up), and the vector's are for the position of object A and object B then yes, you can compare the x coordinate to check, which way to face.
Posted 14 January 2013 - 01:59 PM
Subtract one from the other, if the result is positive it's one way, if it's negative it's the other? That's just a guess by the way, I may be wrong...
Posted 15 January 2013 - 04:21 AM
Edited by saaughmraat, 15 January 2013 - 04:22 AM.
Posted 19 January 2013 - 02:21 AM
Thanks for the replies.
It was 2D and they are position vectors so I have compared x's and now I know of alternatives for more complex situations, thanks again.