Untitled

mail@pastecode.io avatar
unknown
python
a year ago
594 B
10
Indexable
Never
extends KinematicBody2D

var direction:Vector2
var gravity_speed=4500
var jump_speed=-1500
var descend_speed=50
var horizontal_speed=600

var pace=1.0 #speed_factor

func _physics_process(delta):
	
    delta *= pace

	## Movement ##
	direction.y += gravity_speed * delta + descend_speed * Input.get_action_strength("ui_down")
	
	if(is_on_floor()):
		if(Input.is_action_just_pressed("ui_up")):
			direction.y=jump_speed
	
	direction.x=Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
	direction.x *= horizontal_speed
	
	direction=move_and_slide(direction,Vector2.UP)