-
Simple if/else statement problem
Hi,
I’m creating an expression that controls the orientation of a layer.
x=transform.orientation[0];
y=transform.orientation[1];
z=radians_to_degrees(Math.atan(distanceA/distanceB));//have written distanceA and B to save writing down calculation
if (z >= 270){
[x,y,(z-180)];
}else{ [x,y,z]; }So basically, the layer this code is attached to points to another layer (have only applied this to the z orientation as you can see). The if statement stops the z angle jumping from 89.99 to 270.
Thing is, this if statement didn’t work.. the jump happened anyway.
I had to make a null, and put
x=transform.orientation[0];
y=transform.orientation[1];
z=radians_to_degrees(Math.atan(distanceA/distanceB));
[x,y,z];in the orientation, then reference these values in the visible layer:
x=null's x orientation;
y=null's y orientation;
z=null's z orientation;if (z >= 270){
[x,y,(z-180)];
}else{ [x,y,z]; }for it to work.
Why’s this? Is there a shorter way of doing this?
Cheers
Nick