Hello i was following the roll-a-ball tutorial and after i made the public text on my ball and dragged the text onto it,there is a problem. The text that i want to appear is shown but the iteration of score is not
being shown.
public class Acc : MonoBehaviour
{
public Text capsuletext;
private int capsule;
public Text timertext;
private Rigidbody rb3d;
public GameObject changer;
// Start is called before the first frame update
void Start()
{
capsule = 5;
rb3d = GetComponent<Rigidbody>();
setcount();
}
void Update()
{
setcount();
transform.Translate(Input.acceleration.x, 0,0);
}
public void Jump()
{
rb3d.AddForce(0, 300, 0);
}
public void Rjump()
{
rb3d.AddForce(0, -300, 0);
}
void OnTriggerEnter(Collider collision)
{
if (collision.gameObject.CompareTag("Bound"))
{
SceneManager.LoadScene("Gameover");
}
else if (collision.gameObject.CompareTag("Capsule"))
{
collision.gameObject.SetActive(false);
capsule = capsule - 1; //the score of 5 that is suppose to reduce to 0 is not being shown
setcount();
}
}
void setcount()
{
capsuletext.text = "Remaining : " + capsule.ToString(); //THE "Remaining" IS BEING SHOWN
if (capsule <= 0)
{
changer.SetActive(true);
}
}
}
Do I understand correctly, you see a ball with the word "Remaining:" over it but no count? When you pause the game in editor and you select the text in the inspector, does it also just say "Remaining:"?
– HappiiGamer