move to apply_input_velocity on the subject

This commit is contained in:
2025-02-23 18:25:57 +09:00
parent ca63d4594c
commit 151a757e3e
13 changed files with 142 additions and 62 deletions
+1 -10
View File
@@ -6,16 +6,7 @@ func process_physics(delta: float) -> State:
var input_direction = %Input.direction
if input_direction.length() < 0.05: return %Idle
var move_direction = Vector3(input_direction.x, 0, input_direction.y)
var target_velocity = Vector3(move_direction.x * subject.walk_speed, subject.velocity.y, move_direction.z * subject.walk_speed)
subject.velocity = subject.velocity.move_toward(target_velocity, subject.acceleration * delta)
subject.velocity += Main.gravity_velocity
subject.move_and_slide()
if move_direction.length() >= 0.1:
subject.last_direction = move_direction
var target_angle := Vector3.FORWARD.signed_angle_to(subject.last_direction, Vector3.UP)
subject.skin.global_rotation.y = lerp_angle(subject.skin.rotation.y, target_angle, subject.rotation_speed * delta)
subject.apply_input_velocity(delta, input_direction, subject.walk_speed, subject.acceleration)
if not %Input.walk: return %Run
if not subject.is_on_floor(): return %Fall