BaseFlickerAction
BaseFlickerAction is an abstract base class for actions that randomly toggle a target on and off at a fixed frequency.
It provides the shared timing and random state logic used by flicker-style effects such as FlickerLight, FlickerRenderer, and FlickerGraphic.
Core Functionality
The class provides:
Flicker Frequency
The Frequency field controls how often the flicker state is evaluated in seconds.
For example, a value of 0.1 means the action evaluates the on/off state every 0.1 seconds.
AmountOn Probability
The AmountOn field controls the chance that the target will be on at each flicker tick.
0: Always off0.5: On about half the time1: Always on
Values are clamped to the range 0 to 1.
Realtime Option
The UseRealtime field lets the action ignore Unity time scale:
false: UsesTime.deltaTimetrue: UsesTime.unscaledDeltaTime
This is useful for flicker effects that should continue while the game is paused or slowed down.
Current State Output
The optional IsOn output stores the current on/off state.
You can use this to synchronize other effects with the flicker pattern.
Update Mode Setup
BaseFlickerAction sets the appropriate update mode for a repeating effect:
public override UpdateMode DefaultUpdateMode => UpdateMode.UpdateEveryFrame;
public override UpdateMode RequiredUpdateModes => UpdateMode.EveryFrame;
How It Works
The action accumulates time every frame and evaluates the flicker state when enough time has passed for one or more ticks.
If frame rate drops, it advances by whole ticks and applies only the final state once. This helps keep the flicker cadence stable without doing unnecessary work every frame.
Required Overrides
Inheritors must implement:
This method should enable or disable the specific target type.
Actions can also override:
This is used in the action summary.
Example
FlickerLight is a simple example:
using System;
using JetBrains.Annotations;
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[Serializable, PublicAPI]
[ActionCategory(Category.Flicker)]
[ActionDescription("Randomly flickers a Light on/off.")]
public class FlickerLight : BaseFlickerAction
{
[OwnerDefaultValue]
[Tooltip("The Light to flicker on/off.")]
public LightVar Light;
public override bool CanExecute() => CheckParameters(Light);
protected override string Target => nameof(Light);
protected override void Apply(bool on) => Light.Value.enabled = on;
}
}
With this setup, the base class handles the timing and random on/off decisions, and the derived action only needs to apply the current state to its target.