disable "autoshot" on keypress

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

Hey guys, I have a little question.

I’m making a character control script for my platform game project and I struggle with a little detail…

here’s my code :

	if Input.is_action_pressed("ui_accept"):		
	if grounded:
			jump(jumpForce);

Simple, but my problem is that if i keep m’y jump button pressed, my character will jump again and i don’t want that, i want the player to press the button again. It’s important for me cause I also want the same behaviour for my attack action, I don’t want “autofire”.

Can you help me with this?

Thank you!

And keep going! Godot rock!

Well, if jump, grounded should be turned to false, right?

Remember to turn it to true when hits the ground so it can jump again.

eons | 2016-10-10 13:29

hey, maybe I was not clear with my question (My English is not perfect… so sorry for it).
The problem I have is different, when i press the button, the character jump, no problem with it. But if i keep the button pressed and my character hit the ground, it will jump again.

I don’t want this behaviour, I want the player to release the button then press on jump again if he want to jump a second time.

Do you see what I mean?

c4n4r | 2016-10-10 16:35

:bust_in_silhouette: Reply From: wf192

You can use:

Input.is_action_just_pressed( String Action)
Input.is_action_just_released( String Action)

So that way:

if Input.is_action_just_pressed("ui_accept"):        
if grounded:
        jump(jumpForce);