I’m trying to set up a collision system for a fighting game.
I’m wondering how I can get the enemy to know what move hit them?
Punch or Kick
Height
damage
what reaction animation to play
etc.
I’m not sure how to set this up, any suggestions.
I have a character running around, punching and kicking already, with some basic overlap collision detection, but I need the details, so the other character knows how to react.
Well you have the “Event Hit”. This provides you with information about where the hit occurred (“Hit Location” which is a vector) as well as the “Other actor” (which actor caused the hit).
You could play around that a bit and look if that helps.
I’ll try that, but I stayed away from the Event Hit, because I need an Overlap. A foot during a kick needs to be able to pass through the enemy, like it does in regular fighting games. Not collide like a dynamic reaction, or like you see in real fight simulators.
I found another problem, and it’s with one attack triggering the hit states multiple times.
I have some “Notifies” in the attack animations, to set an active hit range for the move. Between frames so and so, this move can hit the enemy.
If I activate the collision for the attack at the start of that time frame, it will remain active even if it hits, and continue to register collisions, making the enemy go in to the hit state many times in rapid succession.
To fix that, I added “Component Begin Overlap” events to my Hit Volumes. Red collision spheres that can hit the enemy.
If the character is performing an attack, and one of these “Component Begin Overlap” Events is triggered, it will set a variable “Did I Hit Something?” to True, and in turn disable collision for all the Hit Volumes, even if the Active hit frames are not finished.
The reset for if anything was hit, is when an attack is triggered. Set “Did I Hit Something?” to False at the start of the attack.
The trigger for my attack, is a branch asking if that specific attack is in the Hit frames, and if It hasn’t hit anything, turn on collision. Otherwise, turn collision off.