What is wrong here?why isn't it working?

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyDamage : MonoBehaviour

    [SerializeField] Collider collisionMesh;
    [SerializeField] int hitPoints = 10;

    // Use this for initialization
    void Start()

    private void OnParticleCollision(GameObject other)
        if (hitPoints <= 1)

    void ProcessHit()
        hitPoints = hitPoints - 1;
        print("current hitpoints are " + hitPoints);

    private void KillEnemy()

My Unity Screens

Hi Pritam,

Unfortunately, I don’t see any problem. What did you expect to see? What do you see instead?

Try placing the collider on the parent level of the Enemy, to detect a collision you need a rigid body and a collider.

I expected that the enemy will get damage. But it does not work

Send me pics Please

Take the box collider from enemy body and move it to the top level with the rigidbody.

This topic was automatically closed after 14 days. New replies are no longer allowed.

Privacy & Terms