0 votes

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:

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!

asked Oct 10, 2016 in Engine by c4n4r (51 points)

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.

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?

1 Answer

–1 vote

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:
answered Oct 10, 2016 by wf192 (16 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.