• Register

This is Jack - a guy that met Satan and tricked him into promising to never take his soul He wasn't good enough for paradise either, so when he died he ended up in purgatory Death has now brought him back to life to deal with Satan's Halloween Shenanigans, in exchange for a solution to his Eternal Torment

Post feature Report RSS Direction Based Hit Reaction

So my enemies were lacking some reactions to getting hit by weapons among other things that would make things more juicy, I decided to use the morning to implement a simple hit reaction system.

Posted by on

So my enemies were lacking some reactions to getting hit by weapons among other things that would make things more juicy, I decided to use the morning to implement a simple hit reaction system.

My first stop was to add a hit animation in a way that would layer over the rest of the enemy systems, so I created a simple 10 frame animation with one pose to see how it looked, I added this to a separate layer on-top of every other layer. Created an upper body mask so that they could still walk and then I just triggered it upon getting hit:

That worked fine, so then I had to figure out a way of establishing the direction the weapon or projectile was coming through, luckily Unity has a dot product function as well as a working sample in the SDK that recognized forward and behind. I extended this to recognize left and right. I also gave it some tolerance to allow for centered directions, so 8 directions in total and a centered one just to cover all possibilities.

I first tested this using a cube and a sphere:

So now that this was working I went back into 3dsmax and made the 8 directional hit poses, roughly, then brought them back in to Unity and named the accordingly. I then added them all to the hit layer I created and placed them according to direction,

Calling animator trigger based on direction

finished up the transition setup and triggers and voila:


Optimization note: I found this Forum.unity.com about setting triggers with strings and will update my code when I am polishing things up, but for now I just wanted to make sure everything is working as expected


Thanks for reading!

Post comment Comments
BenEnderYT
BenEnderYT - - 14 comments

This honestly looks awesome, getting a lot of mediEvil vibes.

Reply Good karma Bad karma+3 votes
koyima Author
koyima - - 52 comments

yep, that's intentional, so it's nice you can see it

Reply Good karma+2 votes
booman
booman - - 3,651 comments

I love what I'm seeing!
Great animation, character, cartoony art and atmosphere.
Keep up the hard work

Reply Good karma Bad karma+2 votes
koyima Author
koyima - - 52 comments

thanks

Reply Good karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: