Jump to content
Subscribe to GameDev.net Direct to receive the latest updates and exclusive 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 15 January 2013 - 04:21 AM
Edited by saaughmraat, 15 January 2013 - 04:22 AM.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.