UE4/C++ Playing Attack Animation Advice

Hi there,

I’m currently working on a personal project and I’m having some issues playing my attack animation.
I’m using state machines to play my animations as we did in the Simple Shooter project and currently in order to trigger my attack animation to play I’m using a boolean value bIsAttacking(which I think is an overkill thus I’m not happy with it especially the implementation that I have), the issue is that I don’t think I’m doing it the right way and would like to know if there is a better way to implement it.

Here’s the code flow: (A → B: means function A calls B)
WizardCharacter::BaseAttack(within this I set bIsAttacking = true) -->(using a timer) MagicWand::BaseAttack → WizardCharacter::ResetAttackState(false = notAttacking)

The reason I use a timer to call WeaponEquipped::BaseAttack is bc I want to spawn the bullet/cube mid-animation, if I don’t the bullet/cube is spawned at the beginning of the animation. Currently it works fine but I would like to improve the implementation.


Note: I tried setting bIsAttacking at the beginning of WizardCharacter::BaseAttack and then reset it to false at the end of the function(as you can see commented) but that didn’t work, the attack animation was never played.

1 Like

Here’s the state machine:

video link: https://youtu.be/JsMWmbSiI2M

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms