- Home /
create a vector from one point to another point ?
hello,
I just want to create a vector3 (direction) from two points (world position)! a idea ?
thank you
Answer by Brian-Kehrer · Aug 12, 2010 at 09:39 PM
Vector3 newVector = targetPoint - initialPoint;
or
Vector3 newVector = targetTransform.position - fromTransform.position;
Answer by darbotron · Aug 12, 2010 at 10:41 PM
the only thing you need to rmember when doing vector subtraction is that, like all subtraction (i think!), it's non-commutative (i.e. in order to get the answer you want from subtraction it matters which thing you subtract from which).
I remember it like this:
vSourceToDestination = vDestination - vSource;
That's more or less exactly what the previous answer says, but I'm hoping my "destination minus source" thing helps it stick in yr head :)
darbotron
Thanks that's really solve my problem. I was substracting in an inverse way, so that's why the direction wasn't working until i read this.
Thank you for this explanation, I easily solved my problem after reading this.
This is more commonly known as Head-$$anonymous$$inus-Tail rule
Your answer
Follow this Question
Related Questions
Input.GetAxis("Horizontal") problem 3 Answers
Rigidbody + Vector3 3 Answers
Vector3.lerp doest work 1 Answer
How to make Vector3s communicate with Floats? 2 Answers
Vector 3 do/while problem 1 Answer