diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 73b3d40..302d1d7 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -1604,7 +1604,7 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) return # Asset-level config (model-file specific). - var facing_dir : String = str(model_asset.get("modelFacingDirection", "north")) + var facing_dir : String = str(model_asset.get("modelFacingDirection", "south")) # Card-level config (visual identity of this card, not the shared mesh file). var model_scale : float = float(def.get("modelScale", 1.0)) var tint_str : String = str(def.get("modelTintColor", "")) @@ -1840,19 +1840,29 @@ func _idle_rotation(iid: String) -> float: var my_pos : Vector3 = my_body.global_position var best_sq : float = INF var best_dir : Vector3 = Vector3.ZERO - var enemy_ids : Array = _enemy_unit_ids.keys() if _is_enemy_unit(iid) == false \ + var is_enemy_unit : bool = _is_enemy_unit(iid) + var enemy_ids : Array = _enemy_unit_ids.keys() if not is_enemy_unit \ else _friendly_unit_ids.keys() + var found_bodies : int = 0 for eid in enemy_ids: var eb := _unit_bodies.get(eid) as StaticBody3D if not is_instance_valid(eb): continue + found_bodies += 1 var d : Vector3 = eb.global_position - my_pos var sq : float = d.x * d.x + d.z * d.z if sq < best_sq: best_sq = sq best_dir = d - if best_sq < INF and best_dir.length_squared() > 0.001: + if best_sq < INF and (best_dir.x != 0.0 or best_dir.z != 0.0): var flat := Vector3(best_dir.x, 0.0, best_dir.z).normalized() return atan2(flat.x, -flat.z) - base + # Log why closest-enemy failed. + push_warning("[IdleRot] FALLBACK iid=%s is_enemy=%s enemy_ids=%d bodies_found=%d best_sq=%s dir_xz=(%s,%s)" \ + % [iid.substr(0,8), str(is_enemy_unit), enemy_ids.size(), found_bodies, + str(best_sq), str(best_dir.x), str(best_dir.z)]) + else: + push_warning("[IdleRot] FALLBACK iid=%s — body not in _unit_bodies (friendly=%d enemy=%d)" \ + % [iid.substr(0,8), _friendly_unit_ids.size(), _enemy_unit_ids.size()]) # Fallback: fixed north/south heuristic. var flip : bool = bool(_needs_face_rot.get(iid, false)) var dir := Vector3(0, 0, 1) if flip else Vector3(0, 0, -1)