How would one display the UI if it wasn’t based on a game position, and a result of a function:
Ex.
player transform Player;
public text scoreText
(scoreText.text = player.transform.y.ToString();
EX END------------------------------------------------------- ^^^^
My code------------------------------------------------------BELOW
private float score = 0.0f;
public void AddScore(int value)
{
score += value; Debug.Log("Score = " + score);
}
private void OnTriggerEnter(Collider other)
{
// Once the steak collides with an animal it is deleted
Destroy(gameObject);
// Now both objects are deleted upon collison
Destroy(other.gameObject);
if (other.gameObject.CompareTag(“Animal”))
{
scoreManager.AddScore(3);
}
void Update()
{
scoreText.text = score.ToString();
}
I’m obviously skipping a lot, but hopefully it’s helpful enough. The problem is the text just stays at 0 in the game screen because it is displaying the variable and not the data from the function.