Charging Melee Weapon

I’m trying to create a melee system in the ThirdPerson C++ template that uses the mouse button to start an attack, playing a short “raise weapon” animation and once the animation reaches the end if the mouse button is held down there is a charging animation that plays for as long as the button is held. Once the mousebutton is then released the charging attack plays a swinging attack animation that is offset by the time it took to charge which would control where the animation starts playing from. Example: Full charge would play from the start of the swing animation, while short charge plays from closer to the end. This creates a damage system based on the “power” of each swing.

I have implemented the simple attack raise animation playing on mouse click already, now comes the fun part.

So after thinking about it for a little while I came to the conclusion (with my low level of knowledge) that using an anim notify/anim-notify-state event at the end of the raise animation to trigger a check if the player is holding the mouse button would work well. If it is held down, it will then flip a “isCharging” Boolean to true and play the charging animation, and then each tick as long as the mouse button is held a frame count starts and when the mouse button is released the Boolean is flipped to false, and the attack animation plays at the offset frame.

I have been using C++ primarily, but I am aware that powerful things can be done in the animBP. How would I go about implementing this? If there seems like a better way to do it please share your ideas.

I struggled to decide where to post this, if it is better in the C++ section please let me know.

-Thanks

If you set your charging attack up as a Montage, you can put the charge loop into its own section, and use the Montage “Set Next Section” function call. If you use the same section (so you are currently IN the section MeleeCharge, and you SetNextSection to also be MeleeCharge) you will set the Montage up to loop that section. Then, when the mouse button is released, you can just call Jump To Section and jump to the release phase.

You can also use Dynamic Montages for this, though in order to do so you need to set your “charge loop” animation up with the same notifystate so every time it loops, it retriggers itself as a new dynamic montage. If you have that NotifyState listen via the tick event for the mouse release, you can force it to play the Charge Release animation as a new Dynamic Montage.

Which route you go depends on how many chargeable melee attacks you plan to have.