Burst compiler fixes, Cinemachine target binder & camera null-ref fix #36

Merged
lavarius merged 3 commits from feat/burst-compiler-optimization into master 2026-03-13 23:13:26 +00:00
Collaborator

Summary

A collection of runtime bug fixes discovered during the Burst optimization work.


Fixes

FaceTracker.cs — CS0104 ambiguous [ReadOnly]
Qualified [ReadOnly] on BlendshapeSmoothingJob fields as [Unity.Collections.ReadOnly] to resolve ambiguity with Sirenix.OdinInspector.ReadOnlyAttribute.

MovementManager.cs — Burst BC1064/BC1067 struct-by-value errors
Added in modifier to float2/float3/quaternion parameters in all three [BurstCompile] static methods (ComputeCameraRelativeDirection, ComputeSpeed, ComputeRotation). Burst's ABI does not allow vector/quaternion structs passed by value to external functions.

MovementManager.csUnassignedReferenceException: playerCamera
Camera.main is null in Start() when the camera prefab is spawned at runtime by CameraManager. Replaced the eager assignment with a WaitForCamera() coroutine that yields until Camera.main resolves, then assigns it once. Update() keeps a single cheap early-out guard for the brief startup window.


New Feature

CinemachineTargetBinder.cscloses #35

Adds a MonoBehaviour that re-assigns CinemachineCamera.Follow / LookAt at runtime after the player is spawned, fixing cameras that had stale or missing scene references.

  • If CharacterStore.Instance is already set (scene transition), binding happens immediately in Start().
  • Otherwise subscribes to InputSystemSpawner.OnPlayerInputReady and binds when the event fires.
  • Inspector toggles for bindFollow and bindLookAt.

Usage: Add CinemachineTargetBinder to any virtual camera that needs to track the player and tick the desired bind options.

## Summary A collection of runtime bug fixes discovered during the Burst optimization work. --- ### Fixes **`FaceTracker.cs` — CS0104 ambiguous `[ReadOnly]`** Qualified `[ReadOnly]` on `BlendshapeSmoothingJob` fields as `[Unity.Collections.ReadOnly]` to resolve ambiguity with `Sirenix.OdinInspector.ReadOnlyAttribute`. **`MovementManager.cs` — Burst BC1064/BC1067 struct-by-value errors** Added `in` modifier to `float2`/`float3`/`quaternion` parameters in all three `[BurstCompile]` static methods (`ComputeCameraRelativeDirection`, `ComputeSpeed`, `ComputeRotation`). Burst's ABI does not allow vector/quaternion structs passed by value to external functions. **`MovementManager.cs` — `UnassignedReferenceException: playerCamera`** `Camera.main` is `null` in `Start()` when the camera prefab is spawned at runtime by `CameraManager`. Replaced the eager assignment with a `WaitForCamera()` coroutine that yields until `Camera.main` resolves, then assigns it once. `Update()` keeps a single cheap early-out guard for the brief startup window. --- ### New Feature **`CinemachineTargetBinder.cs`** — closes #35 Adds a `MonoBehaviour` that re-assigns `CinemachineCamera.Follow` / `LookAt` at runtime after the player is spawned, fixing cameras that had stale or missing scene references. - If `CharacterStore.Instance` is already set (scene transition), binding happens immediately in `Start()`. - Otherwise subscribes to `InputSystemSpawner.OnPlayerInputReady` and binds when the event fires. - Inspector toggles for `bindFollow` and `bindLookAt`. **Usage:** Add `CinemachineTargetBinder` to any virtual camera that needs to track the player and tick the desired bind options.
Adds a MonoBehaviour that re-assigns Follow/LookAt on CinemachineCamera at
runtime, resolving lost references when the player is instantiated dynamically.

- If CharacterStore.Instance is already set (scene transition / DontDestroyOnLoad),
  binding happens immediately in Start().
- Otherwise subscribes to InputSystemSpawner.OnPlayerInputReady and binds when
  the player's input system fires, covering fresh-spawn flows.
- Exposes bindFollow / bindLookAt toggles in the Inspector.

Closes #35

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Camera.main may be null in Start() when the camera prefab is spawned at runtime
by CameraManager. Rather than crashing, Update() now re-fetches Camera.main each
frame until it resolves, then skips the frame if it's still unavailable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
WaitForCamera() yields until Camera.main is available then assigns it once.
Update() retains a single early-out guard for the brief window before the
coroutine resolves, but no longer does any Camera.main lookup every frame.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lavarius merged commit ee4b34664b into master 2026-03-13 23:13:26 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lavarius/ProjectOverlay!36
No description provided.