How to reset a level by collecting items?!?!

Hello, i need a script for when i collect a collectable object but when you collect all the object it resets the level. thanks!

No one here is going to write up a script for you, but we can push you in the right direction. :wink:

First, if you don’t know how to do something so basic, I think you should get acquainted with the tutorials all over the internet. I’m on them everyday and just can’t help myself. It’s that fun once you get past the first few ‘pits’ of scripting. Not hard at all, just fun.

If your collecting gameObjects, let’s say 10, I would assign a trigger to each of the them. This trigger would add 1 point to an integer variable and when you’ve collected all 10 gameObjects, you can do what was suggested in the selected answer here.

Here’s the 2 for a good starting point for Triggers. Have fun!

you really should learn to write code. It's alot easier to get help from ppl if you type what you understand and someone can just adjust it. but this is an easy script so i'll give you a simple code. There's a bunch of different ways to do this but the main ways are to make the objects inactive (invisible) which you can turn back on at any given time, like if you have to get it from the same point more than once, or call a destroy function which takes the object completely out. Coding is very easy to understand. How you would say it is pretty much how you write it.

var CollectedObjects : int = 0;

var Coin1 : GameObject;

var Coin2 : GameObject;

function Update()

{

       if(CollectedObjects >= 2)

       {

                Application.LoadLevel(1);

                CollectedObjects -= 2;

       }

}

function OnControllerColliderHit (hit : ControllerColliderHit)

{

           if(hit.gameObject.tag == ("coin1"))

           {

                    CollectedObjects += 1;

                    Coin1.active = false;

           }

           if(hit.gameObject.tag == ("coin2"))

           {

                    CollectedObjects += 1;

                    Coin2.active = false;

           }

}

var neededCollectable : int = 5;
var amountCollected : int = 0;

function Start(){
	amountCollected = 0;
}

function Update(){
	if(amountCollected == neededCollectable){
		Application.LoadLevel(0);
	}
}

function OnTriggerEnter(collision : Collider){
	if(collision.gameObject.tag == ("Collectable")){
		amountCollected += 1;
	}
}

This should do it just add a tag called “Collectable” to your collectables, set the collectables collider to is trigger and set the neededCollectable variable to however many collectables you need to pass the level. Hope it helps.