Hello, I want to make player continuously fire if I hold left mouse click. What I’ve made is I updated character’s tick function so it counts deltatime, and when it gets to “deltatime * 20”, only then OnFire() function gets called, if player is still holding left mouse click. Then the variable resets to zero and again counts to deltatime * 20. Is there more rational decision? Because I suppose deltatime is different for every player (Im planning to do multi-player) and the rate can be rather different.
OnPressed - fire once and set the timer to your delay between shots - referencing your actors Fire() function
OnReleased - clear the timer delegate
Another way would be, to have three variables: bool Firing, float Delay (set in editor), float LastShotTime
OnPressed - set firing to True.
OnTick - If firing and CurrentTime > (LastShotTime + Delay) THEN fire and LastShotTime = CurrentTime
OnReleased - set firing to False.