I’m working on a melee mechanic for my game where tapping a a key once will punch but double tapping will throw a block. for some reason this code isn’t working for this purpose. anyone see any reason why?
extends Node3D
@export var DOUBLETAP_DELAY = .25
var doubletap_time = .25
var last_event = "null"
@export var rightAnim : AnimationPlayer
func _process(delta):
doubletap_time -= delta
_right_hand()
func _right_hand():
if Input.is_action_just_pressed("RightHand"):
if last_event == "RightHand" && doubletap_time >= 0 :
rightAnim.play("Block")
print("block")
last_event = "null"
elif doubletap_time < 0:
rightAnim.play("punch")
last_event = "Right"
else:
last_event = "Right"
doubletap_time = DOUBLETAP_DELAY