debug.log does not show up, Why?
public class Timer : MonoBehaviour {
float Seconds;
// Use this for initialization
void Start () {
Seconds = 0f;
}
// Update is called once per frame
void Update () {
Seconds += Time.deltaTime;
if (Seconds == 3.000000) {
Debug.Log("It Works!");
}
}
}
Answer by aditya · Sep 07, 2016 at 04:45 AM
Because you are checking for EXACT 3 Seconds
by using this line if(Seconds == 3.00000)
... this line should be if(Seconds >= 3f)
... Pls mark this as Answer if it helped
Answer by UmairEm · Sep 07, 2016 at 06:02 PM
The value of Seconds
variable would never be exact 3
. This is correct usage in this scenario :
if (Mathf.Floor(Seconds) == 3)
{
Debug.Log("It Works!");
}
Answer by Blue-Cut · Sep 07, 2016 at 09:22 PM
Time.deltaTime
gives you the time in seconds since last update.
60fps ~ 0.016, 30fps ~ 0.033.
So if you have Seconds == 2.999
at one of your frame, it will be Seconds == 3.015
at the next frame, so greater than 3.0.
That is why you should use : if (Seconds >= 3.0f)
Your answer
Follow this Question
Related Questions
I think i wont be able to make an android app 0 Answers
Problems in Admob Script 0 Answers
Console issue 0 Answers
Why are my float rounding themselves out to the lowest int without me coding it out? 1 Answer
[HELP] No info shows up in the console! 0 Answers