The code is not printing remaining hitpoints of the enemy even though I turned on “Send Collision Message” in collisions tab in Particle effects. Also applied Kinematic rigidbody collider along with box collider on enemy. Here is my code below, please help me understand where is the mistake in it. The game is running but it not printing anything on the console.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyDamage : MonoBehaviour
{
[SerializeField] int hitPoints = 10;
private void OnParticleCollision(GameObject other)
{
ProcessHits();
if (hitPoints < 1)
{
KillEnemy();
}
}
private void ProcessHits()
{
hitPoints = hitPoints - 1;
print("Hitpoints remaining: " + hitPoints);
}
private void KillEnemy()
{
Destroy(gameObject);
}
}
Please help me with this.