To understand the logic in these scripts and set everything up including how to make sprite based animations, visit my YouTube tutorial going over all that: https://youtu.be/XQtetgakjTQ
This solution does require you have some way to manage the grounded state for your project, but other than that, it can be imported and used in any 2D project.
With these scripts I have made a melee attack similar to what is in the very popular game Hollow Knight by Team Cherry.