- Home /
using rotation in an if statement
this is what's going on so far... another script is rotating my sun along the x axes... and im getting dodgy shadows at night
in the day the suns rotation on the x never goes above 100 so this should work, i think iv'e worded the if statement wrong can some1 please tell me what i should use instead. thanx.
var Sun : Transform;
function Update(){
if(Sun.transform.rotation.x < 100){
GetComponent("Light").enabled = true;
}
else {
GetComponent("Light").enabled = false;
}
}
Answer by matyicsapo · Jan 13, 2011 at 08:36 AM
http://unity3d.com/support/documentation/ScriptReference/Transform.html
Use transform.eulerAngles
instead of rotation
for while the first is the normal angle thingy(with 360 meaning a full rotation and stuff), the other is a Quaternion
whose components mean different stuff.
Also Sun
is of type Transform
so you should just write Sun.eulerAngles.x
This helped a lot with something similar. Thanks a lot homes!
Your answer
Follow this Question
Related Questions
Script Performance Questions 3 Answers
My backpack script doubt 0 Answers
Problem with Simple Script - Rotation and Data Types 1 Answer
Destorying despite IF Statement 1 Answer
Create file in correct directory 3 Answers