The goal of this project was to create a combat system capable of chaining multiple attack animations with different effects I'll explain right here !
I also made interactions and feedback on hit with an enemy as well as a lock on system to never loose track of the enemy you want to defeat.
Regarding the animations linked to my playable character, I used a mix of Animation BP and Animation Montage.
For basic movements such as walking/running/jumping/dodging, I made everything on the ABP, but for "attack" animations I directly call them into my BP_Character using an array of animation montages I use when the attack button is pressed.
Once an attack is used, an integer increases to go on the next animation in case the attack button is pressed again. (if not, and the animation is canceled/finished, then it comes back to 0 from the beginning of the list)
Specific feedback and behavior are then played depending on the properties set up on the animation montage.
To know which actions the player can do during the attack animation currently played, I use a mix of code inside my BP_character and "Anim Notifies" I trigger to connect the logic between the character and the animation.
Each anim notify serves a purpose to activate, deactivate and tweak parameters during specific timings in the animation.
For example, you can choose to let the player attack again after hitting an enemy or not, let him trigger a different attack at a specific time frame, cancel it with a dodge, a jump etc...
Using these anim notifies let the system be open to a lot of possibilities depending on the kind of vision and game feel the designers want.
To have different kind of effects and feedbacks depending on which attack the enemy took, I use tags defined on any hitbox triggered when the player is in attack animation.
If an enemy gets into an attack collision, his BP will verify the tag of the collision that touched him and behave a certain way depending on the tag.
Example : a regular attack will push the enemy backward while a launcher will push him upward.
To target a single enemy easily, I created a lock on system where, by pressing a button, a trace is used to detect any hit on a valid target in front of the player camera.
This trace can be tweaked to make the detection wider/longer/bigger depending on designers necessities.
Once a hit is valid, the camera will update and follow the hit actor using a timer by event and a "Rotator Interp" to smoothly interpolate between my enemy and the player rotation values over time.
If the player is really close to an enemy, his character can rotate automatically towards the enemy when pressing attack to make positioning less frustrating at close distance.
to make that effect, I almost used the same principle as the lock on but I interp between the character and the enemy location to set the player rotation.
I also use a timeline to make a smooth rotation between the initial player rotation and the one I set afterward.