extends KinematicBody2D onready var _anim_tree = $AnimationTree export var max_velocity = 150 export var base_lateral_friction_coeff = 1.0 var movement_velocity = Vector2.ZERO var grav_velocity = Vector2.ZERO var component_h = 0 var component_v = 0 var on_floor = false func _ready(): self.set_physics_process(true) func _physics_process(delta): var gravity_vector = ProjectSettings.get_setting("physics/2d/default_gravity_vector") var gravity_magnitude = ProjectSettings.get_setting("physics/2d/default_gravity") * 10 * delta var up_vector = gravity_vector * -1 if on_floor == false: grav_velocity += (gravity_vector * gravity_magnitude) var velocity = movement_velocity + grav_velocity if velocity.length() > max_velocity: velocity = velocity.normalized() * max_velocity move_and_slide(velocity, up_vector) if is_on_floor() and on_floor == false: grav_velocity = Vector2.ZERO on_floor = true func _input(event): pass