A while ago I tried to recreate the jump mechanic of Mega Man 9 in Godot. Here is what I came up with:
export (int) var jump_speed = -400 export (int) var gravity = 1200 var jumping = false func _physics_process(delta): if Input.is_action_just_pressed('jump') and is_on_floor(): jumping = true velocity.y = jump_speed if jumping and Input.is_action_just_released("jump"): if velocity.y < -50: velocity.y = -50 velocity.y += gravity * delta velocity = move_and_slide(velocity, Vector2.UP) if jumping and is_on_floor(): jumping = false
No comments:
Post a Comment