What is the best way to find direction between two objects?
Im trying to get a definitive direction being able to say it moved Left or right from the object essentially.
This is being done with the HTC Vive. the player clicks the trigger and an empty object is created and moved to the current location of the controller. the player then moves the controller left or right/up or down from the start point and in return an object matches the movement made by the player.
I know of the page that tells the calculations for direction and distance from one object to another here as this is what i am currently using, however it's not exactly what i need. below is a picture depicting what is happening:
Both instances of the player in the picture are moving the controller right, however what the current calculation(below) returns is incorrect for what i am looking for. and I'm not sure the direction (<--- puns) that i should go to get the desired result which would be both instances should return (.5,0,0)
Vector3 heading = empty.transform.position - rightAttack.transform.position;
float distance = heading.magnitude;
Vector3 direction = heading / distance;
Debug.Log(String.Format("{0} {1} {2}", heading, distance, direction));
The information in this section of the documentation is what i linked to above. not very helpful overall for what i need as i described
Sorry I totally missed that link! Not sure how :P I've read it again but to me its not entirely clear what you are trying to do.