- Home /
How can I compare directions of objects
I'm want to compare the directions two objects are facing, but I'm not sure how to approach it. And by compare i mean like:
if(object.direction != otherObject.direction) {
do something
}
Basically I want to check if the objects are facing the same direction or opposite directions, and do something based on that.
EDIT: Actually, what would be even better if there is a way to normalize all the objects so their rotation initally begins at zero, since some are at different initial rotations. (however i dont wont the actual rotation to be affected)
Answer by mikebelotti · Aug 02, 2012 at 06:47 PM
Sounds like you want the dot product. It'll give you a scalar that you can use to compare the objects' directions.
will it let me check if objects are facing the same direction? Because so far it seems like it only compares whether an object is in front of, or behind you.
read the info in the link that he placed there. there u can find what u want. reading documentation = win
Your answer
Follow this Question
Related Questions
Ternary operator fails, but verbose comparison doesnt? 1 Answer
Duplicated door follows animation of the original 1 Answer
Open a link 1 Answer
Rotation and movement? 1 Answer
Opening a door while holding a key 1 Answer