Level Changing

I have a script for level switching currently, but it is not working. The script uses the oncollisionenter function. i may not be understanding what it is supposed to do but when i run into the object it is supposed to go to the next level but it just collides with the desired object and does nothing.

525286–18568–$Level Switch.js (136 Bytes)

I didn’t look at your code, but is your button to go to the next level set as a trigger? If so, you need to use OnTriggerEnter(). If you use a mouse to click on it, you might want to use OnMouseDown() instead.

function OnTriggerEnter (other:Collider) {
 if(other.gameObject.name == "Exit"){
  Application.LoadLevel("Level 2");
 }
}

does that help?

First off how would i upload the code so i can see it like that.
Second that does help and i will try it when i get a chance.

You wrap it in code tags. They look like

[code]//Your code here[/code]

For your initial problem, you should make sure that the collision is actually being triggered. Put a debug statement in the collision code. Additionally, you should make sure that both parties in the collision meet the criteria in the collision matrix (found at the bottom of the page here).

post the script!! :slight_smile:

i have figured out the issue. i am also using a new script that my friend gave me so all is good.