Hey everyone !
I’ve been practicing a bit with the blueprint system of UE4, and I recently came across a basic problem.
My project is about a turret that is entirely kinematic ( movement system ) but I wanted for fun to create a “Firing Event” where the player is holding a key to load the weapon.
For this reason I used a function called " Get input time down" that sets up a variable called “TimeLeftMousePressed” used for calculing how long i’ve been pressing my left mouse button.
When this variable ( double ) reach a certain value ( let say it reaches another variable called : LoadingTime ) some function are then used to create the shot and manage the ammo system.
But my problem comes when I want the turret to keep reloading and shooting even if the player is still holding the left mouse button after the first shot. In order to do that I need to reset the time sent by my function " GetInputKeyTimeDown".
To be clear i’m searching for a solution that do something like that :
Pressing key ->Start counting → Set variable : TimeLeftMousePressed → If loading time is reached → Reset TimeLeftMousePressed to Zero and restart couting ( from zero )
For instance: if i say that my variable “LoadingTime” is set to 2 seconds it shoud do something like that
- TimeLeftMousePressed : 0
- TimeLeftMousePressed : 1
- TimeLeftMousePressed : 2 ( Loading Time reached → Restart Couting from zero )
- TimeLeftMousePressed : 0
- TimeLeftMousePressed : 1
- TimeLeftMousePressed : 2 ( Loading Time reached → Restart Couting from zero )
…
It’s quite a basic problem, but it seems that i’m stuck on that ( maybe cause I tend to complicate things xD )
I would really appreciate your help on this.
Best Regards