- Home /
How can i detect hits from enemies inside of a player?
I want to detect all enemy attacks from the player itself. So i created trigger collider at the top of normal one, and set second OnTriggerEnter2D (first one is for attacking)
But with this method come problems. I can just bump into an enemy and it'll get hurt, both triggers will sometimes work together and cause unintended results, and finally it just seems like a very clunky and stupid method of doing this. Is any other ways to do this?
Do you mean you put 2 OnTriggerEnter2D in one script? cause you can't do that.. In your OnTriggerEnter2D method you can check the tag of the collided collider, you can also set up collision matrix in project setting.
Answer by JethRow · Nov 25, 2021 at 07:43 PM
Hello, i can help you but you need to be more specific of what effect you are trying to create!
I'm just trying to create so the hit detection on enemy's attack work with script that is attached to player, not enemy
Your answer
Follow this Question
Related Questions
2d edge collider wont destroy? 0 Answers
How do you disable your own Collider? Bugfix 1 Answer
Trigger only one collider? 1 Answer
How to use OnTriggerEnter? (JS) 1 Answer
collider vs collider2d 1 Answer