- Home /
Need some help with 2D combat (example video)
Hi there,
I'm using Physics2D.OverlapCircleAll for 2D combat detection and I'm getting some inconsistent results with my player to enemy hit detection as illustrated in this short video clip here:
https://www.youtube.com/watch?v=4ZoEA1Zc1Us
Any ideas why this is happening? The code is fairly simple, when I hit a button an Attack() function is called. Thanks in advance for checking this out.
Answer by JedBeryll · May 15, 2020 at 08:19 AM
I think it's just because of the radius of the overlap circle. By the time the animation executes, the overlap circle already disappears. You could use a trigger collider in front of the player and keep all enemies in a list which are inside the collider via OnTriggerEnter2D and OnTriggerExit2D and try to apply the damage until the animation finishes, or you can increase the radius of the overlap circle, or position the circle better.
Your answer
Follow this Question
Related Questions
[Conceptual] How to keep from destroying multiple objects? (Only one at a time) 2 Answers
How do I find colliders within a cross or dot product of a vector to a target from the player? 1 Answer
A Fighting Games Hit boxes 1 Answer
2D One, Two, Three Attack Combo 2 Answers
How should i make sword combat ? 1 Answer