0 votes

im trying to implement a player jumping without the character changing direction in mid-air. Now, ive seen a similar post however the difference is that my script is not using the "on_ground" or "floor" detect. it uses the x axis position to determine the floor.

can someone explain where and what code I would need to implement the solution. just to be clear here is a link to the video demonstrating the problem:


and here is the code:


id appreciate any advice and solutions thank you

Godot version v3.4.4 stable.official(419e713a2)
in Engine by (51 points)

1 Answer

0 votes
Best answer
func _physics_process(delta):
    var axis = get_input_axis()
if axis == Vector2.ZERO:
        if  Jumping == false:
            animatedSprite.animation = "Cap_off_idle"
            apply_friction(ACCELERATION * delta)
        if  Jumping == false:
            animatedSprite.animation = "WalkRight"
            apply_movement(axis * ACCELERATION * delta)

All I did there was indent movement lines to the right, so they are under condition of jumping being false. If I understood your code correctly, that means moving will not be allowed when in the air

by (7,745 points)
selected by

Thanks for your response. the sprite still changes in mid-air.
However i posted a similar question in Reddit and received a few answers whereby placing
in line 57 : "if !Jumping" as well as indenting lines 58 & 59 - fixed the mid-air movement problem and with your advice on moving code to the right it solved the problem. this is the result :


Many thanks for your help!

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.