OnColliderEnter doent work

when my player hit a wall nothing happends.
this is my script.

using UnityEngine;
using UnityEngine.UI;
public class playerDead : MonoBehaviour
{
    public Text points;
    public int savedPoints;
    public int highestPoints;
    //public GameObject player;
    void OnColliderEnter(Collider col)
    {
        Debug.Log(col.transform.name);
        savedPoints = int.Parse(points.ToString());
        if (savedPoints >= highestPoints)
        {
            highestPoints = savedPoints;
        }
    }
}

OnCollisionEnter(Collision collision)
{

}

1 Like

its works but i got now an input string was not correct format error??

hey it’s a bit hard to say anything about that without info :slight_smile:
i guess you are talking about this line:
savedPoints =int.Parse(points.ToString()); ?
if so try
savedPoints =int.Parse(points.text);

1 Like

thank you, that works!