extends Move class_name Walk func should_enter(input) -> String: input.actions.sort_custom(moves_priority_sort) return input.actions[0] func update(input: InputPacket, delta: float): player.velocity = get_new_velocity_from_input(input, delta) player.move_and_slide() func get_new_velocity_from_input(input: InputPacket, delta: float) -> Vector3: # Get the XZ input direction based on player's input relative to the camera var forward := camera.global_basis.z var right := camera.global_basis.x var movement_direction := ( forward * input.movement_direction.y + right * input.movement_direction.x ).normalized() movement_direction.y = 0 # save off last movement direction if movement_direction.length() > 0.2: player.last_movement_direction = movement_direction # if we're not stuck, then it's okay to set the velocity player.floor_normal = player.get_floor_normal() player.ground_slope_input = (PI / 2) - player.velocity.angle_to(player.floor_normal) var new_velocity = player.velocity.move_toward( movement_direction * (player.walk_speed + player.ground_slope_input * player.walk_speed), player.acceleration * delta ) return new_velocity