Question by
BrownBoii333 · Dec 06, 2015 at 02:44 PM ·
text
Question about roll a ball tutorial
I am a beginner with Unity and was doing the roll a ball tutorial. Now the winText shows up before i hit play, but after i do it just shows no writing where the text should be appearing, though if i zoo out on the scene and look at the canvas i see the box where the text should be. In the inspector, after i click play, the box to write my text becomes empty, then when i stop te simulation, it shows that it says "You Win! using UnityEngine; using UnityEngine.UI; using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
public Text countText;
private Rigidbody rb;
private int count;
public Text winText;
void Start ()
{
rb = GetComponent<Rigidbody>();
count = 0;
countText.text = "Count: " + count.ToString();
winText.text = "";
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Pick Up"))
{
other.gameObject.SetActive(false);
count = count + 1;
countText.text = "Count: " + count.ToString();
}
}
void SetCountText()
{
countText.text = "Count: " + count.ToString();
if(count>=12)
{
winText.text = "You Win!";
}
}
}
Comment