- Home /
How do I make script in C# the result will execute if all the boxes is fill up?
I make a put in a box game. How do I make script in C# the result will execute if all the boxes is fill up and if all the boxes not fill up the result will not execute?
put a trigger on the box and colliders on the objects, and then have a script on the box that says
void OnTriggerEnter () {
putInBox += 1; //this is an integer
IsTheBoxFull();
}
void IsTheBoxFull() {
if (putInBox >= 5) {
execute code
} else {
still need to put more in box
}
}
and then another script that lets you pick up objects and drop them into the box with the mouse
sorry for the short explanation.. the game is 3D.. my current code is like this :
void Update () {
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "cube" || other.tag == "sphere")
{
print ("You Win!");
}
}
}
I want to make the "you win" will appear if cube and sphere is successfully placed in the box.
So in my code I use an integer where each time I count +1
and then you can just check if (integer = 2) { print ("You win!"); }
Your answer
Follow this Question
Related Questions
[HELP WANTED] Blender FBX to Unity Animation Issue 0 Answers
Leaderboard system 2 Answers
Restart the scene without changing the scoreboard 0 Answers
How to save coins with PlayerPrefs 2 Answers