- Home /
how to check if every plattform is visited
Hi!
i already tried to public this question but it seems i made a mistake.
Im very new in Unity and im working on a game based on a worldquest from WoW.
The Player (Cube) have to reach the Goal (Blue plattform) but he have to visit every other plattform exactly 1 time(which become green then). Its Game over when he walk over a plattform for the 2. time or when he touch the goal while there are still unvisited plattforms.
Now im looking for a way to check if all plattforms are visited to the time he hit the goal. But i have no clue how to do that.. My first Idea was to give every plattform an boolean visited who is initial false and then is set to true by hit. But how i check then if every of these booleans is true?
Answer by cgklutts · Dec 22, 2019 at 12:24 AM
List<bool> platformsHit;
void Start()
{
platformsHit = new List<bool>();
}
// code here somewhere to change the bools for individual platforms
void CheckIfAllHit()
{
int falseCount = 0;
bool canFinish = false;
foreach(bool platformHit in platformsHit)
{
if(platformHit == false)
{
falseCount++;
}
}
if(falseCount > 0)
{
canFinish = false;
} else { canFinsish = true; }
}
thank you very much. It helped. I had some trouble to understand your code. Actually as a beginner i prefer to get things explained rater then just get the Code. But still it pushed me in the right direction so i was able to find my own solution. thanks <3
Your answer
Follow this Question
Related Questions
Roll a cube help 0 Answers
How to make a "pressure sensor" of sorts that when rolled over switches to another scene 2 Answers
Rolling Cube with Rigidbody? 5 Answers
Trying to rotate a 'domino' with gravity enabled 0 Answers
Mechanim Eliminates Gravity 0 Answers