- Home /
Object display fine but when i move them, they disappear
I have created a timer for my hidden object game, i use a script to display the time with a variable using Text Gui and a empty game object call GUIHolder to contain the script, it works fine but the problem is when i move them i wont see them any more on the main camera, any way to set the position of this timer on the main camera without disappearing them? Any help would be appreciated. Tnx! Here is my script using UnityEngine; using System.Collections;
public class TimeText : MonoBehaviour {
public GUIText timeText;
//Countdown to 0 start from 30s mark
public float timer = 30.00f;
void Update()
{
timer -= Time.deltaTime;
timeText.text = "Remaining Time " + timer.ToString("0.00");
//what to do if the time is over
if (timer <= 0) {
timeText.text = " ";
Application.LoadLevel(3);
}
}
}
Answer by Kiwasi · May 22, 2014 at 01:47 AM
GUIText use a different coordinates system to every other GameObject
From the documentation:
"Rather than being positioned in World Coordinates, GUI Texts are positioned in Screen Coordinates, where (0,0) is the bottom-left and (1,1) is the top-right corner of the screen."
Chances are you are trying to position a GUIText at somewhere higher than (1,1) or lower than (0,0). Hence off screen and not rendered.
Your answer
Follow this Question
Related Questions
How would I make the text bigger on this script? 1 Answer
Displaying my variable on a gui text 0 Answers
Detecting GuiText click 0 Answers
Problem Displaying Score on GUI text 0 Answers
GuiStyle attachment problem 1 Answer