Fix: model facing default (south/+Z) + clear game state on rematch

Model facing: GLB models exported from Blender arrive in Godot facing +Z,
not -Z. Changed _facing_to_base_angle default case from 0 (north/-Z) to
PI (south/+Z). Explicit "north" case added. Updated admin dropdown label
from "Default (north)" to "Default (south / Blender GLB)" to match.

Stale game state: when matchmaking.match_found is received, clear Game.state
so the new GameScreen always calls send_ready() rather than rendering the
previous (ended) game's state. Fixes same-players-re-match ending up in
the already-completed session.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-16 08:18:28 -04:00
co-authored by Claude Happy
parent 42a2834e03
commit 085249b5c4
3 changed files with 6 additions and 3 deletions
+1
View File
@@ -257,6 +257,7 @@ func _on_server_push(type: String, payload: Variant) -> void:
var sid : String = str(d.get("gameSessionId", ""))
var oname : String = str(d.get("opponentDisplayName", "Opponent"))
var orank : int = int(d.get("opponentRankScore", 0))
state = {} # Clear any stale previous-game state before new session starts
session_id = sid
opponent_name = oname
match_found.emit(sid, oname, orank)
@@ -811,12 +811,14 @@ func _resolve_anim_track(ap: AnimationPlayer, action_lower: String) -> String:
## Convert a model's exported facing direction string to a base angle in radians.
## The angle represents atan2(dir.x, -dir.z) for the direction the model faces
## when rotation.y == 0. All animations and movement share this offset.
## GLB models exported from Blender arrive in Godot facing +Z (south) by default,
## so "south" / unset / null all map to PI. Explicitly pass "north" for -Z models.
func _facing_to_base_angle(facing: String) -> float:
match facing.to_lower():
"south": return PI
"north": return 0.0 # model faces -Z (Godot's natural forward)
"east": return PI / 2.0
"west": return -PI / 2.0
_: return 0.0 # "north" / default: model faces -Z
_: return PI # "south" / default / null — model faces +Z (Blender GLB)
## Returns the rotation.y (radians) that makes a unit's model face its opponent
## across the board, given its stored base angle and team-flip flag.