Pass ForgeDocs Product page

Component

Spotlight Target

Dims the screen everywhere except a soft circle with a pulsing ring around one object, to lead the player's eye in a tutorial.

Add Component > Pass Forge > Spotlight Target API reference

What it does

A Spotlight Target makes its object the target of the Spotlight effect: the rest of the screen dims and a soft circle with a pulsing ring stays clear around the object. It leads the player's eye in a tutorial: "pick up this sword", "open this door", "this is your base". It also suits a guided moment in a puzzle game, or a reveal in a cutscene.

The circle fits the object's renderers by itself, so it sizes to a crate or a whole building. The target sets the look: how dark the rest gets, the color it dims toward, how soft the edge is, and the ring's color, width and pulse.

Switch the component on to light the object and off to end it. With several targets enabled, only the one enabled last is lit. The Spotlight effect needs no Volume.

Add it

  1. Select the object to light, such as the tutorial's first pickup.
  2. Choose Add Component > Pass Forge > Spotlight Target.
  3. Run Tools > Pass Forge > Set Up Effects once per project and turn Post Processing on for the camera. The Inspector warns and offers a button for each while one is missing.
  4. Look at the Game view. The screen dims except a circle around the object, with a pale yellow ring that pulses.
  5. Switch the component off in the scene, and switch it on from your tutorial step.
Inspector
Spotlight Target Inspector

There is no GameObject menu item for it.

Settings

SettingWhat it does
Fit To RenderersSize the circle to fit the object's renderers and its children's. On by default. Off uses Radius around the object's position.
RadiusShows while Fit To Renderers is off, or while the object has no renderer to fit. Radius of the circle in world units, at least 0.01. Default 1.
PaddingExtra room around the object, in world units, at least 0. Default 0.3.

Look

SettingWhat it does
DimHow dark the rest of the screen gets, from 0 to 1. Default 0.75.
Dim ColorThe color the rest of the screen dims toward. Default dark blue gray.
SoftnessHow soft the circle's edge is, as a share of its radius, from 0 to 2. Default 0.35.
Ring ColorColor of the ring around the circle, with HDR. Zero alpha draws no ring. Default pale yellow.
Ring WidthWidth of the ring in pixels, from 0 to 20. Default 3. Zero draws no ring.
PulseHow much the ring pulses to catch the eye, from 0 to 1. Default 0.5. Zero holds it steady.
Pulse SpeedHow fast the ring pulses, from 0 to 12. Default 4. Zero holds it still.

Notes the Inspector shows

  • "This object has no renderer to fit, so the circle uses Radius", with Fit To Renderers on and no renderer on the object or its children.
  • "Does not show: only one Spotlight Target works at a time, the one enabled last", naming the one lit instead.
  • Set Up Effects and Turn On Post Processing warnings while one is missing.

Common jobs

Light one object for a tutorial step

  1. Add a Spotlight Target to each object your tutorial points at, and switch every one off.
  2. In each tutorial step, switch that object's target on, and switch it off when the step is done.

Only the target enabled last is lit, so switching on the next one moves the spotlight there.

Light a spot with no object

Add Add Override > Pass Forge > Gameplay > Spotlight to a Volume and set Mode to Screen Point. Set Screen Point from 0,0 at the bottom left to 1,1 at the top right, and Screen Radius as a share of the screen height (default 0.2). Use it for a HUD element, such as the health bar.

Restyle every target

The Volume's Spotlight override also has Dim, Dim Color, Softness, Ring Color, Ring Width and Pulse, which take over the target's own while ticked. Pulse Speed is set only on the target. Intensity at zero turns the spotlight off.

Draw the eye without dimming

Set Dim to 0 and keep a ring. Only the pulsing ring shows around the object.

From a script

using System.Collections;
using PassForge.Effects;
using UnityEngine;

// Dims the screen around one object for a tutorial step.
public class TutorialSpotlight : MonoBehaviour
{
    [SerializeField] PassForgeSpotlightTarget m_Target;   // on the object to point at, switched off in the scene

    public void Show(float seconds)
    {
        StopAllCoroutines();
        StartCoroutine(ShowFor(seconds));
    }

    IEnumerator ShowFor(float seconds)
    {
        m_Target.dim = 0.85f;                              // darker than the default
        m_Target.ringColor = new Color(0.4f, 1f, 0.6f, 1f);
        m_Target.enabled = true;                           // the one enabled last is lit
        yield return new WaitForSecondsRealtime(seconds);  // real time, so it counts in a paused tutorial too
        m_Target.enabled = false;
    }

    // The target lit now, or null when none is enabled.
    public static PassForgeSpotlightTarget lit => PassForgeSpotlightTarget.current;
}

Good to know

  • One at a time. Only the target enabled last is lit. Switching a target on again makes it the lit one.
  • One per object. An object holds one Spotlight Target.
  • Renderers. Fit To Renderers uses the enabled renderers on the object and its children, read again when children change. A switched off renderer is left out of the fit.
  • Prefab Mode. A target in a prefab open in Prefab Mode lights only that prefab's view, so it does not take the spotlight from the game.
  • Screen effect needs. The spotlight needs Set Up Effects and Post Processing on the camera. With a target enabled it shows without a Volume.
  • Pixels. Ring Width is in pixels, so the ring keeps its width on screen at any distance.