I am trying to get a block (Player) to be destroyed when it touches a wall. The script is attached to a wall game object, so it checks if the player has collided with the wall every frame. I have looked around and tried different approaches but to no luck. I'm still quite new and i'm shure that i'm just missing something simple. Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class Wall_collision : MonoBehaviour { void OnTriggerEnter(Collider collider) { if (collider.gameObject.CompareTag("Player")) { Debug.Log("I WORK"); //Does not } } }
If you're using OnTriggerEnter, make sure the player's collider has "IsTrigger" checked. If you do not want to use a trigger collider on the player, then use OnCollisionEnter instead. In both cases, make sure the player object is actually tagged as "Player".