Vixen
02b45cc4
csharp
public sealed class CameraDirectorSystem

Picks the live shot for every CameraDirector, blends when the pick changes, and moves the real camera there.

No guide page documents this yet — the page shows what the code says about itself.

As a system

Phase
LateUpdate

Remarks

Ties go to the shot enabled most recently. Priority decides, and when two shots share a priority the one whose Enabled most recently became true wins — which is what a designer means when they wire two triggers to two cameras and give neither of them a number. Breaking the tie by entity id instead would be deterministic and useless: the same shot would win for ever, and the second trigger would appear to do nothing.

An interrupted blend freezes rather than nesting. When the pick changes during a blend, the state the director had produced that frame becomes the outgoing side of the next one — one snapshot, no stack, and no pop at the moment of the interruption. Cinemachine keeps the whole chain alive and evaluates it recursively, which is smoother under a rapid series of cuts and unbounded in cost; this is the trade, and the visible cost of it is that a handheld shake on the outgoing shot stops moving for the length of the second blend. A blend that is not interrupted keeps evaluating both shots live, so the common case pays nothing for this.

It runs after VirtualCameraSystem in LateUpdate, and it writes the camera entity's LocalTransform rather than its WorldTransform — so the transform pass in PreRender resolves the camera and anything parented to it, in the same frame, by the ordinary route. A camera rig with a weapon model hanging off it therefore does not lag the camera by a frame.

Fields and properties (2)

  • public CameraBlendTable? Blends

    Per-pair blend rules, or for the director's default only.

  • public SystemAccess Access

    What this system reads and writes.

Methods (6)

  • public override JobHandle Update(in SystemContext context, JobHandle dependency)

    Runs the system.

  • public Entity LiveCameraOf(Entity director)

    The shot a director is currently taking, or Null.

  • public Entity BlendingFrom(Entity director)

    The shot a director is blending out of, or Null.

  • public float BlendProgressOf(Entity director)

    How far through a blend a director is: 0 while not blending, 1 the moment it ends.

  • public void Reset(Entity director)

    Forgets everything about a director, so its next frame is a cut rather than a blend.

  • public void Direct(World world, GameTime time)

    Chooses, blends and writes, for every director in the world.

Used by (4)

  • PlayerRigThirdPersonShooter
  • CameraDirectorTestsVixen.Engine.Tests
  • RigVixen.Engine.Tests
  • RigVixen.Engine.Tests