- Home /
if (transform.rotation == Vector3(0,0,0)) doesn't work!
Okay, So i'm trying to print text when my camera reaches a curtain rotate position, ideally I want to print text between a value range, like instead of just 0, 0 up to 1. I tried this script, but the console just won't print my text ever, just prints the else text even when the transform.rotation is dead on Vector3(0,0,0) ! whats wrong with the script and how can get it to look between a range rather than just 0.
function Update() { if(transform.rotation == Vector3(90,180,0)) { print("America"); } else { print("failed!"); }
}
thanks - caius
Answer by SteveFSP · Nov 21, 2010 at 08:43 PM
You are trying to compare a Vector3 with a Quaternion.
I think what you really want is:
if(transform.eulerAngles == Vector3(90,180,0))
@The OP: Note that even with the above correction, it's very likely that the conditional will never evaluate to true due to floating-point error and Euler-angle aliasing. If the goal is to deter$$anonymous$$e when a particular orientation has been reached, I'd recommend using some other method (for example, using the quaternion dot product).
@Jesse Anders Thats correct, I'm trying to deter$$anonymous$$e when the camera has reached a particular orientation, but a problem is I want the orientation to have a radius. I've looked at the Quaternion dot product, as far as not understanding the concept, I can't see how i would implement it.
Answer by TGAM123 · Jul 29, 2011 at 05:58 PM
i have the same problem...i need to launch game when player looks at 3d text... :S any ideas???
Your answer
Follow this Question
Related Questions
top down 3d camera rotation question 2 Answers
Using the accelerometer to rotate Camera 1 Answer
Problem with rotation of objects 0 Answers
Adding y position? 4 Answers
I am getting a problem with moving and rotating a camera! 1 Answer