- Home /
How to call a function when something happens in the game once conditions are met?
hello, I'm looking for solution to increment levels for my game. Logic should be like this: When I get score of 3, transition starts and level becomes level 2, then when I get 6, cycle repeats. Currently I have something like this, but in this case I should make bool variables to play code once for passing each level which isn't correct. How could this situation be solved?
if (score.currentScore >= 3 && isPlayed == false)
{
isPlayed = true;
StartCoroutine(MakeTransition());
}
Thank you!
Answer by logicandchaos · Feb 19, 2020 at 01:09 PM
You do it when your score goes up, like somewhere in your code you will have score.currentScore++ then right after that you put if (score.currentScore >= 3) then your make transition or whatever.. also don't use 3 use a vaiable, is it always going to be 3 more points to the next level? if so you should have if (score.currentScore >= level*pointsNeededToAdvance) or something like that, then you can use the same code for every level.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Dissolve shader script little proplemo, help me 0 Answers
Global Fog Messy Transition Between Objects and Skybox 1 Answer
nut and bolt object construction system? 0 Answers