The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

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:
            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!

in Engine by (55 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:
        jump(jumpForce);
by (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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.