OnCollisionEnter fails to destroy Player GameObject
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerDeath : MonoBehaviour {
public GameObject DeathTrigger;
void OnTriggerEnter(Collider other)
{
if (other.tag == "PLAYERCUBE")
{
Destroy (other.gameObject);
Destroy (gameObject);
}
}
}
I am at my wit's end as to how to destroy the Player gameObject upon collision. It should be just a simple little code, but I just am unable to get the PLAYERCUBE destroyed by colliding into an object.
I have dragged this code onto a gameObject cube that I have tagged "Death", and I want to make sure that the Player gameobject (tagged PLAYERCUBE) will get destroyed upon colliding it.
Here's a screenshot for context.
Your answer

Follow this Question
Related Questions
AddForce to object using OnCollisionEnter via a pre-existing AddForce? 0 Answers
Compare Tag on Collision (Collider.CompareTag) 2 Answers
I'm trying to play a sound OnCollisionEnter, but something isn't working right. Can you help me ? 0 Answers
Why does it display an error? 2 Answers
How do you make a destroy command with timer and with tag. 2 Answers