- Home /
Pick up objects to destroy one object.
Hi, I'm making a game where you need to collect 5 objects in order to destroy one.
Ex: You need to 5 coins in order to break the crate.
Thanks.
Comment
Is there a question ? What is the problem ? What can't you do ?
Answer by slayer29179 · Aug 09, 2012 at 09:51 AM
var coinsCollected = 0;
var Crate : GameObject;
function OnTriggerEnter(col : Collider)
{
if (col == "Coin")
{
coinsCollected += 1;
}
}
function Update()
{
if (coinsCollected == 5)
{
Destroy(Crate);
}
}
:)
Your answer
Follow this Question
Related Questions
Destroy All Objects In The Scene??? 1 Answer
How to activate an object when another object deactivates? 1 Answer
destroy and create objects 1 Answer
Pick up objects 2 Answers