This question was
closed Oct 19, 2018 at 05:20 PM by
IT-NESTER for the following reason:
The question is answered, right answer was accepted
Question by
IT-NESTER · Jun 08, 2018 at 11:36 AM ·
c#updateupdate functionupdate problemdebug.log
void Update() problem
Hello. I has the problem. When I use this script (for example)
public int forChecker = 10;
void Update()
{
forChecker -= 1;
if(forChecker == 0)
{
print("forchecker was ended");
}
}
So problem is in console. It was debugging to console every frame. How I can fix that? P.S. I need only one Update when forChecker = 0. How I can do this?
(FixedUpdate isn't helps)
Comment
Best Answer
Answer by Vicarian · Jun 08, 2018 at 01:29 PM
You should probably review some C# coding tutorials (or JS if you're using that for some reason). This can be taken care of simply by using a boolean value:
public int forChecker = 10;
bool isDone = false;
void Update()
{
if (!isDone)
{
forChecker -= 1;
if(forChecker == 0)
{
print("forchecker was ended");
isDone = true;
}
}
}
Follow this Question
Related Questions
how's the relationship between updates? 0 Answers
Do Something Once 1 Answer
Game crashing when im trying to use Inapp update(Unity) 0 Answers
fixed update is not being called 1 Answer