func _input(event):

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

So, im using this

func _input(event):
	var right = Input.is_action_pressed("move_right")
	var left = Input.is_action_pressed("move_left")
	var jump = Input.is_action_just_pressed("jump")

have my input code separated from the func _physics_process(delta), becase i’ve read that it can be beneficial to make the inputs on a separate input function.
and then calling it with:

if _input('jump'):
			$Sprite.flip_h = false
			$AnimationPlayer.play("Jump")

and right and jump respectively,
now the walking works just fine, but Jump does not, the PC does not either jump or play the animation, but it works if i directly put Input.is_action_just_pressed("jump"), instead of _input('jump'),
what is the reason for this? an

:bust_in_silhouette: Reply From: jgodfrey

Your _input function isn’t returning anything - or if it is, you haven’t shown that above. Based on the way you’re calling the function, it looks like it should return a boolean that represents whether the specified event was just triggered. If that’s indeed what you’re trying to do, change your _input function to be:

func _input(event):
    return Input.is_action_pressed(event)

Now, when you call the function using _input("jump"), it will return true if the jump event was just fired or false otherwise. It should work the same for any event you pass in to it.

Is that what you’re after?