using UnityEngine;
using System.Collections;
public class countdowntimer : MonoBehaviour
{
public float timer;
public float timerLimit = 30.0f;
public GUIText timerText;
// Use this for initialization
void Start ()
{
timer = timerLimit;
SetTimerText ();
}
// Update is called once per frame
void Update ()
{
timer -= Time.deltaTime;
SetTimerText ();
if(timer <= 0.0f)
{
print ("You Lose!");
timer = timerLimit;
}
}
void SetTimerText()
{
timerText.text = "Time Left: " + timer .ToString("f0");
}
}
the problem is it wont print the message in this case YOU LOSE! i have the same problem with my win script aswell. everything else works it just wont print when the float is equal to or less then 0.0f. what is going on?
I can confirm that both scripts have no errors. I have tested them by themselves with only the necessary objects and they functioned as expected. So it must be something in the way the scene is setup. Or some ghost in the machine.
This is a list of my best guess issues. I know some are redundant. Sorry.
Are the scripts in the scene?
Is more than one object changing the
gui text?
Are all of the public variables
assigned correctly?
Are your tags set with correct
spelling/capitolization?
Is the On trigger function on an
object with a collider set as
trigger?
Does one object that’s colliding have
a rigidbody?
have you tried restarting Unity or moving everything to a new project?
Others may add to this list if you think of anything.