Home > OS >  Score Not Updating
Score Not Updating

Time:04-07

I have been trying to make an OnTriggerEnter Score system and it has not been updating and is showing no errors so am I doing something wrong that I dont know about here is my Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class ScoreManger : MonoBehaviour
{
    public TextMeshProUGUI MyscoreText;
    private int ScoreNum;
    // Start is called before the first frame update
    void Start()
    {
        ScoreNum = 0;
        MyscoreText.text = ScoreNum.ToString();
    }

    void update() {
        MyscoreText.text = ScoreNum.ToString();
    }

    public void OnTriggerEnte2D(Collider2D col){
        if(col.tag == "Score"){
            ScoreNum  = 1;
            Debug.Log("It Worked");
             MyscoreText.text = ScoreNum.ToString();
             Destory(col.gameObject);

        }
    }
}

CodePudding user response:

You spelled OnTriggerEnter2D wrong.

Or you haven't marked at least one of the colliders you are interacting with as a trigger.

Or you haven't attached the script to a gameobject.

  • Related