Hiya, So I have a player and an enemy set up in Unity5 each with a Rigidbody2d component set to Body Type Kinematic and they both have a BoxCollider2D attached with IsTrigger active.
My script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DamageHandler : MonoBehaviour {
int health = 1;
void OnTriggerEnter2D(){
Debug.Log ("Trigger!");
health--;
if(health <= 0){
Die();
}
}
void Die(){
Destroy(gameObject);
}
}
So I seem to be doing something wrong. When I run into my enemy this script doesn’t go off. Not even the debug goes off. So obviously something isn’t connecting I’m just not sure if the script is wrong or if they changed the way collision works in Unity.
Any help would be awesome.