Detect key release when using action mapping?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nichefect
:warning: Old Version Published before Godot 3 was released.

From what I understand from the Godot tutorials, it’s best to use the action map for setting the control scheme of a game. I’m in a situation where I need to detect when a key is released and I’m wondering how one would do this because there is no function like Input.is_action_released(“an action”).

The reason I need to know this is because I have a character animation for walking, but when the character stops walking the animation will play out its last loop before stopping. I need to know when the key is released so that can tell the animation to stop as soon as the character stops walking.

:bust_in_silhouette: Reply From: tiernich

Well, i use:

func _input(ev):

    if ev.is_action("btn_walk") and !ev.is_pressed() and !ev.is_echo():

!ev.is_pressed() could be used for that

there is also a project from Andreas Esau and Mariano(i think) on GitHub. Check this link: link

and a discursion about it: link

and finally a tutorial(from Esau again, he rocks) about animating a character the way you want: link

Thanks for all the resources, I’ll check them out and see what I come up with.

Nichefect | 2016-04-26 12:37

There’s also ev.is_action_released(action_string) :slight_smile:

Hinsbart | 2016-04-28 12:47

@Hinsbart thanks for the info!

tiernich | 2016-04-28 14:04