5 func should_enter(input) -> String:
6 input.actions.sort_custom(moves_priority_sort)
7 return input.actions[0]
10 func update(input: InputPacket, delta: float):
11 player.velocity = get_new_velocity_from_input(input, delta)
12 player.move_and_slide()
15 func get_new_velocity_from_input(input: InputPacket, delta: float) -> Vector3:
16 # Get the XZ input direction based on player's input relative to the camera
17 var forward := camera.global_basis.z
18 var right := camera.global_basis.x
19 var movement_direction := (
20 forward * input.movement_direction.y + right * input.movement_direction.x
22 movement_direction.y = 0
24 # save off last movement direction
25 if movement_direction.length() > 0.2:
26 player.last_movement_direction = movement_direction
28 # if we're not stuck, then it's okay to set the velocity
29 player.floor_normal = player.get_floor_normal()
30 player.ground_slope_input = (PI / 2) - player.velocity.angle_to(player.floor_normal)
31 var new_velocity = player.velocity.move_toward(
32 movement_direction * (player.walk_speed + player.ground_slope_input * player.walk_speed),
33 player.acceleration * delta