I have a player that is supposed to be destroyed when it touches some sphere’s but that code is not working.
Could someone please help, here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerdeath : MonoBehaviour
{
void OnTriggerEnter(Collider collision)
{
if (collision.gameObject.CompareTag("Sphere1(Clone)")||
collision.gameObject.CompareTag("Sphere2(Clone)")||
collision.gameObject.CompareTag("Sphere3(Clone)")||
collision.gameObject.CompareTag("Sphere4(Clone)"))
{
Destroy(collision.gameObject);
Debug.Log("You dead");
}
}
}