Does anyone have a script that would allow me to change cameras? If not, could someone point me to a tutorial or something? Thanks. Now for the real question: I have a game where you are flying in a spaceship and when you fly too close to a planet it loads a level (namely the planet level). I used the AND operator for this:
Code:
In addition to the errant ')', you've confused your <= and >= ... I formatted your code to make it easier to see.
if ( transform.position.z >= 6088.709 && transform.position.z <= -5826.924
// if z is greater than 6088 and less than -5826
&& transform.position.x >= -5928.328 && transform.position.x <= 5926.727
// and x is greater than -5928 and less than 5926
&& transform.position.y <= 5954.533 && transform.position.y >= -7152.666 )
// and y is less than 5954 and greater than -7152
{
Application.LoadLevel(1);
}
You need to flip the checks on 'z', and it should work. It'd be easier to spot this kind of error if you did your checks in the same order. i.e. "if x is greater than 1 and less than 2" and stuck to that format for y and z.
However, as Jesse said, there are better ways to implement this functionality, but this will fix your problem in the interim.