my code isnt detecting or something when i press the button in the input map and nothing is happening and i cant figure out why, nothing really helped and im making a gun and my hitscan isnt working
_on_draw()
isn’t run very often, you probably mean to use func _input
for your shoot action, because it’s run for every input.
1 Like
how do i check for specific inputs? it triggers on every action even when moving the mouse sry im not that experienced with coding
I’m not sure what the first three lines of your _on_draw
were supposed to do, but the is_action_just_pressed could be better off in _input
func _input(event: InputEvent) -> void:
if event.is_action_pressed("shoot"):
print("Shot")
visible = true
If you want it to always disapear after being shown you can use your timer after the action, but I’d recommend using a Timer node instead
func _input(event: InputEvent) -> void:
if event.is_action_pressed("shoot"):
print("Shot")
visible = true
# wait 0.1 then set back to invisible
await get_tree().create_timer(0.1).timeout
visible = false