Periodic shooting

From CPC Game Making
Revision as of 15:00, 27 September 2025 by Timothy (talk | contribs) (Created page with "<syntaxhighlight lang="gdscript" line> var waiting_to_shoot = false func _input(event: InputEvent) -> void: if event.is_action("ui_right") and waiting_to_shoot == false: waiting_to_shoot = true await get_tree().create_timer(0.4).timeout print('A shot was fired!') waiting_to_shoot = false </syntaxhighlight>")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
var waiting_to_shoot = false


func _input(event: InputEvent) -> void:	
	if event.is_action("ui_right") and waiting_to_shoot == false:
		waiting_to_shoot = true
		await get_tree().create_timer(0.4).timeout
		print('A shot was fired!')
		waiting_to_shoot = false