I am making a game and part of it is navigating through obstacles. The player is a cube and the obstacles are cubes and i have a 2D Box Collider and 2D Rigidbody(with gravity turned off) on each. This is the script i have attached to the obstacle prefab.
using UnityEngine;
using System.Collections;
public class PlayerCollision : MonoBehaviour {
void OnColliderEnter2D (Collider2D coll) {
if(coll.gameObject.tag == "Player") {
Destroy(gameObject);
}
}
}
When I run the game and run the player into the obstacle nothing happens. Any help is appreciated, thanks in advance!