- Home /
Application.Loadlevel when z greater than x
I have a script to load a level when the sphere's (which is the player) z is greater than 8 but it doesn't do anything
if (transform.position.z > 8) { Application.LoadLevel("LVL2"); }
are you sure the Z actually goes over 8? do you have scene named LVL2 included in build settings?
Like smallbit said, hope you have this in the update function
you have done what exactly? can you zip the project and upload so I can look into it tomorrow when I am back home?
Answer by nightbane30 · May 09, 2015 at 06:51 PM
Does it give you any errors? You may want to consider storing the transform's positional values in temporary variables (that seems to do the trick quite often).
Got the answer. Your load lvl script has a lowercase U for Update. Change it to this:
#pragma strict
function Update() {
if (this.transform.position.z >= 8) {
Application.LoadLevel("LVL2");
}
}
Let us know if you still have any problems!
Answer by Stobby · May 24, 2015 at 06:52 AM
Simple check: did you include the level in your build? Put a Debug.Log function in the IF body to check whether conditions are met
Your answer
Follow this Question
Related Questions
Discrepancy Between Editor and Build World Transform Positions 1 Answer
How can I Instantiate a prefab (projectile) consistently from the character? 0 Answers
Moving object with transform.position ignore other objects even if they collided 1 Answer
Does it make any difference whether position is an integer or a float? 2 Answers