Survival Gathering System Help

Hey guys, I would appreciate some help here. So I’m working on a survival game and I’m currently working on my resource gathering system.

How I’ve set it up (which could be a bad way, and if it is please tell me) is by attaching a collision box to my tree actor and if the player character is inside the collision box and presses LMB, it takes 1 health away from the tree, and adds 1 wood to the player inventory. When the tree health reaches zero, it deletes the tree.

This worked pretty well, until I realized that in most survival games the player can hold LMB down and it automatically gathers every time the character swings for as long as they hold it. So my question today is, how do I add this into my game, while keeping the gather rate in sync with my tree chopping animation?

P.S. I thought about adding a loop with a delay the same length as my chopping animation, but I feel like this is a clunky way of doing it and it would screw up down the line.

I would suggest you want to be able to adjust the gather time.
Whether you have a progress bar or not is something for you to consider.

I would suggest that you do this by registering: if the key is being pressed or gather state time is 100%, while within the resource collision box. An interface is probably a good idea for this.

When the gather time is 100% AND they are NOT still gathering use an anim notify to tell the animation it can finish after the current sequence.

You could also play around with driving the anim play rate to better sync with your gather time, or if the gather time is not variable you could sync the gather time to the animation time (ie 3 swings = 1 wood).

Hope that helps, but lots of ways to do it.