Ok so i have a player, a weapon(sword) and an enemy. The sword is attached as a child to the hand bone of the player and has a box collider. I want to detect collisions with the enemy so i can kill it.
using UnityEngine;
using System.Collections;
public class WeaponCollision : MonoBehaviour {
void Update () {
}
void OnCollisionEnter(Collision col) {
Debug.Log ("Collision");
if (col.gameObject.tag == "Enemy") {
Destroy(col.gameObject);
}
}
}
this script is attached to the weapon object, but its not working, the “Collision” is not being logged either.