loading map

hi, I am trying to write a script for:
load next scene when I kill my Monkey ( I made in Blender)

what I do???

this Is My Monkey:
510985--18151--$Monkey.JPG

hello???
there is some one here?

Use a

Application.LoadLevel("Levelnamehere");

thanks

is right??

var explosion : Transform;

function OnTriggerEnter( hit : Collider )
{
	  if(hit.gameObject.tag == "wormProjectile")
	  {
			Destroy(hit.gameObject);
			var exp = Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
			Destroy(gameObject);
			Application.LoadLevel("first_map");
	  }
}

It looks right - did you test it to see if it works? You have to build the levels (the level you are currently in and the first_map level) before testing it.

yes, I made the map, but it don’t work

Remove all of this:

Destroy(hit.gameObject);
var exp = Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
Destroy(gameObject);

It’s not needed, since you load a new level, so it vanishes anyway.

you don’ t understand, I am doing a script for when I DESTROY the object, he load the map.

Are you getting any errors at all, or is it just doing nothing? I’d also check to make sure everything has rigidbodies/colliders attached to them.

Should you be using OnTriggerEnter, or OnCollisionEnter.

I do understand.

Loading a map destroys all objects.

Destroying an object ends the script.

You destroy it before you load the level, therefore the level does not load.

Don’t destroy it.

For the Application.loadLevel() function to work, you need to have the scenes part of your build path in your build settings.

File → Build settings… → add it to “scenes in build”, it should make it work.

And you do not need the code to destroy the gameObject unless you want the player to see some effect and you want to have a nice fade to the next scene.