The enemy is suppose to start damaging the player when they collide, but it seems like the “OnTriggerEnter” function is not even being called.
This is the player “BoxCollider”
Player BoxCollider
and this is the enemy “BoxCollider”
Enemy BoxCollider
The script is attached to the enemy
Damage on collision script
using UnityEngine;
using System.Collections;
public class DamagePlayer : MonoBehaviour {
private bool inVolume = false;
private PlayerStats player;
void Start()
{
player = new PlayerStats ();
InvokeRepeating ("Damage", 1, 1);
}
void OnTriggerEnter(Collider obj)
{
Debug.Log ("entered");
if (obj.gameObject.CompareTag("Player")) {
inVolume = true;
}
}
void OnTriggerExit(Collider obj)
{
Debug.Log ("exited");
if (obj.gameObject.CompareTag("Player")) {
inVolume = false;
}
}
void Damage()
{
if (inVolume)
player.Health -= -5;
}
}
Console shows no errors.