Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Tato64 |
Hello, wonderful community.
Im here again asking for your help in trying to separate the outcomes of a key TAP (very short press) and a key HOLD (holding down the key).
What im trying to do is:
- Start the reload when the player TAPS R
- Check ammo when the player HOLDS R
I’ve managed to achieve both correctly, but not at the same time.
With everything i tried, i end up with either the reload starting too when i try to check the ammo, or the reload starting when i finish checking ammo. Here’s the relevant code:
#CHECK AMMO
if !Gunvars.isreloading and Input.is_action_just_pressed("reload"):
$Ammocheck.start()
print("ammocheck start")
if Input.is_action_just_released("reload"):
$Ammocheck.stop()
print("ammocheck cancel")
#RELOAD
if Input.is_action_just_pressed("reload"):
if Playervars.playergun == "Pistol (pickup)":
$Pistol.call("reload")
Basically, CHECK AMMO works if you hold R down for 0.5 seconds (The duration of “Ammocheck” timer), this cancels if you interrupt the key hold.
RELOAD, on the other hand, always works, the bottom line is that i want to be able to check my ammo without reloading too.
I’ve been trying to figure this out for some time now but after a long day im burned out
Thanks in advance!