[Question] Impact effect bug when enemy hitting player

I found a bug when the enemy hits the player just outside of his range when you move out side of the range then back in the partial effect will play several times not just the once. not sure how I am going to fix this. Also was wondering if it was going to get fixed in the course.

It sounds like you’re retriggering the OnTriggerEnter() method. This is a pretty specific set of circumstances that need to happen, and I wasn’t able to reproduce it directly, but if what I think is happening is happening, then all we need to do is make sure that we can’t call OnTriggerEnter again.

Add this to your OnTriggerEnter code, at the point in the code where we know we’ve hit our target:

Destroy(GetComponent<Collider>());

Ok well that fixed it. Its a really weird bug ya its just bc the game object is still there when it hits but alos the collider is on it to so if you move away from the object when its hitting you it doesn’t get destroyed right away. after that if you move back to it the collider is still there. and destroying the collider did work. So no more bug yaaa. :smiley: Thanks for the help.