- Home /
GuiText instantiation at position?
Hi Everybody! I'm doing the Pong game and I just wanted to know why this code doesn't work! I have a prefab that is my GameObject with a GUIText component in it and I just want it to instantiate on the screen based on the ball's position. So here's what I have:
void OnCollisionEnter(Collision col){
if(col!=null){
Vector3 a = Camera.mainCamera.WorldToViewportPoint(transform.position);
Object s = GameObject.Instantiate (Prefab,a,Quaternion.identity);
}
}
The reason why I have a prefab is that I want the GUIText to play an animation next spawned, then it just kill himself after the animation. The problem is that any GUIText that I spawn, it spawns on (1,0) coordinates on the screen, but the WolrdToViewportPoint coordinates are right! Any help? Thanks in advance!
Your answer
Follow this Question
Related Questions
Position Gui Text Universally 1 Answer
Background hides text. How to solve that? -1 Answers
Show a target above the player 0 Answers
Spawning Enemies off the screen w/ scrolling background 1 Answer
Disable Gui text on Minimap 1 Answer