what _input(event) loop used for?i can stop all input by gui_disable_input.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bgegg

is there any other usage?

regarding gui_disable_input,i think it can use when i pause the viewport.
extends Node2D

var toggle:bool

func _ready():
	get_tree().get_root().gui_disable_input = true

func _input(event):
	if Input.is_action_pressed("pause"):

func _pp():

What’s the question here? “Any other usage” other than what? That you can disable the reception of input events in a viewport doesn’t make _input useless in any way.

njamster | 2020-07-16 17:43

:bust_in_silhouette: Reply From: dustin

The _input(event) function is called by godot everytime you press a key.

for example, if you press the up arrow key, godot will call the _input function and specifies which input with the event variable. (the event value will be a string that you set in the project settings)

thanks for comment.for example,what is difference func _process(delta) loop?
which is can operate character movement.

func _process(delta):
    if input.is_key_pressed(key_a)

bgegg | 2020-07-17 07:50

you can choose any of them. both work very well!

dustin | 2020-07-17 08:18

i can not understand which is difference.is there any advantage to using input loop ,not a process loop?

bgegg | 2020-07-17 21:14

there is basically no advantage. they are both the same.

dustin | 2020-07-18 02:10

thanks.yes i understand about this.just in case,i use input loop for key event.

bgegg | 2020-07-18 10:06