- Home /
compare 2 vector3 variables
hey, probably its a silly question, but i wanted to compare 2 vector3 variables, and obviously i tried " if(thisVector3 > otherVector3) do something;" but it does not work, i can use something like if (thisVector3.x > otherVector3.x)do something if (thisVector3.y > otherVector3.y)do something if (thisVector3.z > otherVector3.z)do something but in case i have to do it again, but it does not look organized. any ideas are much apreciated. thank you very much.
Answer by cmpgk1024 · Dec 16, 2013 at 01:02 AM
thisVector3.sqrMagnitude > otherVector3.sqrMagnitude
Just to clarify for anyone who stumbles across this one: The answer provided will not actually deter$$anonymous$$e if the two vectors are equivalent; it will compare only their magnitudes(squared), ignoring their direction. While this makes perfect sense for ">" and "http://docs.unity3d.com/ScriptReference/Vector3-operator_eq.html
Your answer
Follow this Question
Related Questions
Compare Vector3 3 Answers
Comparing two coordinates in a Vector3 2 Answers
Finding rotation 0 Answers