fix: third-person camera orbits player facing + robust animation handling

Third-person camera:
- Camera offset now follows player's forward direction using basis.z
- Smoothly orbits behind player when they turn
- Looks at player's head area (y+1.5)

SkinnedPlayerModel:
- Creates AnimationPlayer programmatically if GLB doesn't have one
- Copies animations from armature's animation_data to the player
- Handles both direct actions and NLA tracks
- More detailed debug output for scene tree and animation state
This commit is contained in:
2026-06-22 22:02:30 -04:00
parent c033247f75
commit a2956635c0
2 changed files with 73 additions and 23 deletions
+11 -4
View File
@@ -748,11 +748,18 @@ func _process(_delta: float) -> void:
if not _player or not is_instance_valid(_player):
return
# Third person camera follow
# Third person camera follow — orbit behind player's facing direction
if _third_person and _third_person_camera and _third_person_camera.current:
var target_pos = _player.global_position + Vector3(0, 2.0, -4.0)
_third_person_camera.global_position = _third_person_camera.global_position.lerp(target_pos, 0.1)
_third_person_camera.look_at(_player.global_position + Vector3(0, 1.0, 0))
# Get the player's forward direction (on XZ plane)
var forward = -_player.global_transform.basis.z
forward.y = 0
forward = forward.normalized()
# Position camera behind and above player
var cam_offset = forward * -4.0 + Vector3.UP * 2.5
var target_pos = _player.global_position + cam_offset
_third_person_camera.global_position = _third_person_camera.global_position.lerp(target_pos, 0.12)
# Look at player's head area
_third_person_camera.look_at(_player.global_position + Vector3.UP * 1.5)
if _debug_ui_panel:
_debug_ui_panel.visible = SettingsManager.show_debug_ui