From de81a6f2f39d8b66866530582eedb7bcfc1898b2 Mon Sep 17 00:00:00 2001 From: Luis Gonzalez Date: Fri, 7 Aug 2026 15:09:41 -0700 Subject: [PATCH] Fix: StagingAmbiance must never drive a rig-owned camera (zoom/shake regression) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Self-inflicted, found by the operator the moment they pressed Play: "the camera is so far zoomed in and shaking". StagingAmbiance rides Env_SeabedKit.prefab, which Game.unity instantiates as well as ArtStaging — a placement that predates this session and was harmless while the component only pulsed flora. The camera lissajous drift added in b407f7cd6 then wrote _cam.position every LateUpdate against PrototypeCameraRig's follow, pinning the camera to the authored _camBase (0, 1, -10) while the rig lerped toward its desired (2.50, 16.72, -9.01). Measured before: camera y oscillating 1.157 <-> 13.559, max 7.43 units per tick. Measured after: y settles 16.658..16.709 (target 16.72), span 0.051, max step 0.004 — a ~1800x reduction in per-tick jitter. Gate on the presence of PrototypeCameraRig, not on a scene name (scene-name checks are banned by CLAUDE.md). Verified both directions: ArtStaging has no rig so its drift still runs; Game.unity has one so the drift is correctly inert. Note for next time: two `refresh_unity scope=scripts` calls reported compile_requested=false and the editor kept running the STALE assembly, so the first verification pass showed the guard "not working" when it simply was not loaded. scope=all mode=force was required. Confirm a behavioural fix by probing runtime state (_cam == null), not by re-reading the source. 304/304 EditMode green. Co-Authored-By: Claude Opus 5 (1M context) --- .../Scripts/Client/Presentation/StagingAmbiance.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Assets/_Project/Scripts/Client/Presentation/StagingAmbiance.cs b/Assets/_Project/Scripts/Client/Presentation/StagingAmbiance.cs index 05fe242be..e04b83bcc 100644 --- a/Assets/_Project/Scripts/Client/Presentation/StagingAmbiance.cs +++ b/Assets/_Project/Scripts/Client/Presentation/StagingAmbiance.cs @@ -68,10 +68,17 @@ namespace ProjectM.Client void OnEnable() => CacheCamera(); + /// + /// NEVER drive a camera that a real rig owns. This component rides Env_SeabedKit.prefab, which Game.unity + /// instantiates as well as ArtStaging — so on 2026-08-07 the drift below wrote _cam.position every + /// LateUpdate against PrototypeCameraRig's follow, slamming the camera from its intended y~15.7 back to + /// the authored y~1.5 each frame. Live symptom: "so far zoomed in and shaking" (measured: y oscillating + /// 1.16 ↔ 13.56, 7.4 units per tick). Gate on the RIG, not on a scene name — scene-name checks are banned. + /// void CacheCamera() { var cam = Camera.main != null ? Camera.main : Object.FindFirstObjectByType(); - if (cam == null) return; + if (cam == null || cam.GetComponent() != null) { _cam = null; return; } if (_cam != cam.transform) { _cam = cam.transform; _camBase = _cam.position; } }