Fix NPCs walking backwards

Avatars called Godot's look_at(), which points the node's -Z axis at the target,
but the rig's face (eyes/brows/mouth/focus disc, and the Blender successor) is on
+Z. Every walking NPC therefore faced away from its movement direction.

- add the pure yaw_towards(direction) helper (+Z forward) and use it in both
  movement paths and the reaction face-turn
- fix the head-turn offset to the same +Z convention (basis.z)
- test +Z/+X/-Z/arbitrary directions; recapture targeting screenshot
- TODO bug item moved to DONE, MEMORY records the convention

Headless 209/209.
This commit is contained in:
zwitschi committed 2026-11-01 12:30:41 +01:00
1 parent a7daae8a14
commit 0eb17e3bb4
6 files changed
+53 -9

No files matched your search

+17
View File
@@ -55,6 +55,23 @@ func test_idle_styles_are_known() -> bool:
ok = ok and style in allowed
return TestUtils.check(ok, "idle styles stay in the catalogue")
func test_yaw_faces_the_movement_direction() -> bool:
var a := TestUtils.check(is_zero_approx(NpcAvatar.yaw_towards(Vector3(0, 0, 1))),
"+Z is the neutral facing")
var x_dir := NpcAvatar.yaw_towards(Vector3(1, 0, 0))
var b := TestUtils.check(is_equal_approx(x_dir, PI / 2.0),
"+X turns a quarter turn")
var back := NpcAvatar.yaw_towards(Vector3(0, 0, -1))
var c := TestUtils.check(absf(absf(back) - PI) < 0.001, "-Z is a half turn")
var direction := Vector3(0.4, 0, -0.9).normalized()
var yaw := NpcAvatar.yaw_towards(direction)
var facing := Basis(Vector3.UP, yaw) * Vector3(0, 0, 1)
var d := TestUtils.check(facing.dot(direction) > 0.999,
"the avatar's +Z face points along the walk direction")
var e := TestUtils.check(is_zero_approx(NpcAvatar.yaw_towards(Vector3.ZERO)),
"zero direction falls back to neutral")
return a and b and c and d and e
func test_queue_slots_are_spaced_and_unique() -> bool:
var seen := {}
var ok := true