I already have a jump in place. I just want my character to move more on the x axis when i jump.
[2D] How to make character jump more horizontally
Welcome to the forums @Odysst!
If you want to move further on the X axis, you can add some to the velocity on the X axis to go further. If I understand how the code above works, this should give a bit more horizontal force for longer jumps.
# other code above
var Jumping = Input.is_action_pressed("Jump")
if Jumping && onGround:
velocity = Vecto2(velocity.x, JumpForce)
# add extra X velocity in the direction of the X velocity
velocity.x += 40 * velocity.sign()
local_Hold_Time = Jump_Hold_Time
elif local_Hold_Time > 0:
if Jumping:
velocity = Vector2(velocity.x, JumpForce)
# optional - add extra X velocity over time
# velocity.x += 40 * velocity.sign()
else:
local_Hold_Time = 0
local_Hold_Time -= delta
a year later
Megalomaniak added the Godot Help tag .