- Home /
2D Sidescroller - Best method for attack hit detection?
Greetings, brethren.
My current project is a 2D sidescroller, and I am about to begin programming some basic combat, starting with player attacks.
Could I get opinions on the best method for figuring whether an attack had hit an enemy? I recall in the Lerpz tutorial, they did this by checking if an enemy was inside an attack range sphere, and dealing damage accordingly, but this seems to lack precision.
Perhaps I could have a box that moves about and resizes accordingly? Or maybe attach a trigger on the player's weapon?
What do you guys think would be the best way?
~ADDENDUM~
Specifically, I'm asking about this for melee attacks using a large sword. The player would be able to attack upwards, while standing normally, and while crouching.
Can you provide more information on the kind of attack you want to create? Are you talking about projectiles or melee or something else? The solution for each would be different.
Your answer
![](https://koobas.hobune.stream/wayback/20220612092416im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Vector3 == comparison efficiency and float precision 5 Answers
How to use double-precision floats in a shader 1 Answer
clicking and attacking different animations 1 Answer
Pause Menu Problems 2 Answers
zombie attack script 1 Answer