Post 21: Directional Hit Reactions

I decided to add a small feature that would add a bit to the visuals. The idea was to determine which side of a character an incoming hit has come from and then tailor a directional animation that would reflect that direction.

My first stop was Mixamo for some directional hit reactions. Pretty standard stuff, the intention being to replace them if I have time. I gave these the z-axis stripping treatment that I’ve given all the other animations, created montages and enabled root motion.

My next step was to figure out how I could retrieve the attack data. As I hadn’t implemented an On Collider based hit detection system, I had to think out side the box.

What I thought about was:

    • Taking the position of the character being hit.
    • Taking the position of the character doing the hitting.
    • Finding the angle of attack by comparing the two on a standardised axis.
    • Outputting that to a select function with the animation montages attached to.

Per usual, this is an overly simplified way of explaining what happened, but the above represents the four parts to making this work. All in all, it turned out exactly how I needed it to be and I’m able to move on.