So, I’m trying to do the Roll-A-Ball tutorial and I’m at section 7. I didn’t find a better place to ask this so here goes. I’m trying to get the GUIText box to display properly, however, I keep getting UnassignedReferenceException: The variable countText of PlayerController has not been assigned. You probably need to assign the countText variable of the PlayerController script in the inspector. Now, I made sure to get my script as close to the video shows as possible and yet I still get this problem. Here’s my code, obviously I’m doing something wrong but I don’t know what. If anyone can help give pointers, that would be greatly appreciated.
using UnityEngine;
using System.Collections;
public class PlayerController: MonoBehaviour
{
public float speed;
public GUIText countText;
private int count;
void Start()
{
count = 0;
SetCountText();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis(“Horizontal”);
float moveVertical = Input.GetAxis(“Vertical”);
Vector3 movement = new Vector3(moveHorizontal,0.0f,moveVertical);
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == “PickUp”)
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText ();
}
}
void SetCountText()
{
countText.text = "Count: " + count.ToString();
}
}