CinematicCamera - jimdroberts/FishMMO GitHub Wiki

Description

CinematicCamera moves the camera along a spline path for cinematic effects in FishMMO. It supports smooth position and rotation transitions, optional look-at targets, and user input to skip the cinematic. This component is used to create immersive cutscenes or guided camera movements.


API Access

Fields

  • public SplineContainer SplineContainer

    Container holding the spline path for the cinematic camera movement.

  • public float SpeedInUnitsPerSecond

    Speed at which the camera moves along the spline, in units per second.

  • public float RotationSmoothStart

    Normalized point (0-1) on the spline where rotation smoothing stops being applied.

  • public float RotationSmoothStrength

    Strength of the smoothing applied to the camera's rotation.

  • public Transform LookAtTarget

    Optional target for the camera to look at. If set, camera rotates towards this target.

  • private Transform cameraTransform

    Cached reference to the camera's transform.

  • private float t

    Normalized progress along the spline (0=start, 1=end).

  • private float splineLength

    Total length of the spline path.

Methods

  • public IEnumerator MoveToNextWaypoint(Action onComplete, bool allowInputSkip = false)

    Coroutine to move the camera along the spline to the next waypoint. Parameters: - Action onComplete: Callback invoked when movement is finished. - bool allowInputSkip: If true, allows user input to skip to the end. Returns: Coroutine enumerator.

  • public void Reset()

    Resets the camera's progress along the spline to the start.


Basic Usage

Setup

  1. Attach the CinematicCamera component to a camera GameObject in your scene.
  2. Assign a SplineContainer with a valid spline path to the component.
  3. Optionally, set LookAtTarget to have the camera focus on a specific object.
  4. Adjust SpeedInUnitsPerSecond, RotationSmoothStart, and RotationSmoothStrength as needed for your cinematic.

Example

// Example 1: Start Cinematic Camera Movement
// Attach CinematicCamera to your camera and assign a spline in the Inspector.

StartCoroutine(cinematicCamera.MoveToNextWaypoint(OnCinematicComplete));

// Example 2: Allow User to Skip Cinematic
StartCoroutine(cinematicCamera.MoveToNextWaypoint(OnCinematicComplete, true));

void OnCinematicComplete()
{
    // Actions to perform after the cinematic ends
}

Best Practices

  • Ensure the SplineContainer has a valid spline assigned before starting the cinematic.
  • Use LookAtTarget for dramatic focus or to highlight important objects.
  • Allow user input to skip long cinematics for better user experience.
  • Reset the camera after each cinematic to prepare for future use.
⚠️ **GitHub.com Fallback** ⚠️