ActionCancel is a module for instantly cancelling actions. It’s very common nowadays in combat systems to have pretty… unreliable action cancelling methods, such as stopping all animations loaded in the target’s Animator, which is not really the ideal method.
One of the main problems with using timing based cancelling methods (such as checking if the character is stunned when the animation hits a specific event marker) is that:
Sometimes, stuns may last shortly, and specially in long animations, at the point you check if the character has been stunned, the stun may have disappeared already.
Stuns will not necessarily mean you want that character to cancel its actions. For developers who use non-specific character state structures (for example, no “Stunned” state, but instead a “CantMove” state, which will only make the character unable to move, not necessarily unable to use skills, which gives us better control over states), using an event-based action cancelling method is much better and more solid.
You may not want to cancel actions necessarily when the character is applied a state, such at instant hits that don’t apply any long stun but just deals damage. This is only possible with a method like the one this module offers.
Additionally, ActionCancel can be used for script intercommunication, such as stopping a Dash action when another action is about to be performed.
Made small changes to the module, using dot for the default funcions and colon only for the necessary (Disconnect). Changed slightly the type checking as well to a better structure.