Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Sakura37 |
I want to make a double jump for my player, i have this code from a tutorial but it doesn’t work.It only jumps once. Also, what values are better for jumping?
var jumps_left=2
var jump_power = -185
var gravity = 15
var velocity = Vector2()
func _physics_process(delta):
jump()
velocity = move_and_slide(velocity, Vector2.UP)
func jump():
if is_on_floor():
jumps_left=2
if Input.is_action_pressed("ui_up") and jumps_left>0:
if velocity.y>0:
velocity.y=0 #if falling- ignore fall velocity
velocity.y += jump_power
jumps_left -= 1
velocity.y += gravity