Use the State System to apply temporary public-property values while gameplay conditions such as aiming, running, or entering water are active. Abilities and other gameplay logic own the condition; States supply its values.

Create a State

  1. Open Tools > Opsive > Ultimate Character Controller > Setup Manager > Scene. Select Add Managers under Manager Setup and confirm State Manager appears on the scene’s Game object.
  2. Select the state-enabled component or nested ability, movement type, view type, or item module. Configure its normal values before initialization; these become runtime Default values.
  3. Expand States, select the plus button, and choose Create New Preset. Save in a project-owned folder. For Add Existing Preset, choose one created for the same concrete owner type.
  4. Select the preset asset, use Add Property… for the public getter-and-setter properties it should override, and enter their values. See Presets for asset editing and nested values.
  5. Return to the owner. Give the row a unique, case-sensitive State name matching its gameplay trigger.
  6. Drag it to the required priority. Keep the fixed Default row last. Save the owner scene/prefab and preset.

Use an ability or action module for sequences, spawning, or collision queries; the preset stores property changes for a condition those systems activate.

Combine States

Choice Result
Store only changed properties Unlisted properties retain Default or another active State’s values.
Place a State nearer the top It applies last and wins overlapping properties. Nonoverlapping properties still combine.
Add Run to the Zoom row’s Blocked By An active, unblocked Run suppresses Zoom’s entire preset. Keep the blocker on the row to suppress.
Share a preset among same-type owners Each owner gets runtime-bound delegates; the asset values remain shared. Duplicate the asset for independent tuning.
Use Persist Copies current owner values into properties already stored in that row’s preset asset. Confirm the owner and shared asset first.
Use Activate in Play Mode Toggles that row directly for a property check. Test the real gameplay trigger separately.

Default captures normal public values and remains active. Deactivation restores the affected Default properties, then remaining active, unblocked presets reapply from lower to higher priority.

A blocked row retains its active flag but skips its values and visible active marker. Blocking considers whether the blocker is itself blocked: with A blocked by B and B blocked by C, active C can suppress B and allow active A to apply.

States list showing Shield and Default in bold with (Active) during Play Mode while the other item states are inactive.

A GameObject-based change updates registered owners with the matching State name. UCC maps relevant character child objects and the attached camera to the character. An item initialized while a character State is active receives that State during initialization. For an external object, deliberately use StateManager.LinkGameObjects and unlink when the relationship ends.

Manage shared names

Mapped State Name fields offer a searchable popup: select an entry, enter a name and choose Add, or choose Open Editor. The complete editor is at Tools > Opsive > Ultimate Character Controller > Utility > State Names.

Create a project map through Assets > Create > Opsive > Ultimate Character Controller > Utility > NameMap, assign Name Map, and version it with its editable CSV. The first Add to a new map prompts for that CSV location. Order By > Name Ascending/Name Descending changes presentation; Read Only Files supply selectable entries that remain read-only. The workstation remembers its selected map, so verify it on each developer machine. Existing scene/prefab names retain their assignments and case.

Verify in Play Mode

  1. Record the owner’s normal value and trigger its real gameplay condition. Confirm the row becomes bold with (Active) and only stored properties change.
  2. Activate an overlapping State. Confirm the top row wins; test Blocked By and confirm suppression removes its active marker and values.
  3. End the conditions. Confirm remaining States recombine, then the last deactivation restores Default.
  4. Test matching camera/item owners, including equipping an item after activation. Stop Play Mode and confirm authored rows and asset references persist.

For an inactive row, check exact name/case and owner initialization. For no property change, check the preset’s concrete owner type, stored properties, public getter/setter, and blockers. For unexpected shared edits, restore the asset or assign a duplicate before changing it.

Activate through code

Opsive.Shared.StateSystem.StateBehavior is the component owner; StateObject is the nested serializable owner. Both expose States, SetState(string, bool), StateWillChange(), and StateChange().

Use the GameObject overload for a shared condition and optional global event:

StateManager.SetState(character, "Zoom", true);

StateManager.SetState(character, "DamageFlash", true);
StateManager.DeactivateStateTimer(character, "DamageFlash", 0.25f);

The timer schedules deactivation only, so activate first. SetState(object, State[], string, bool) targets one owner. ActivateState(State, bool, State[]) is the Inspector row path; these narrower operations do not send the manager’s global event.

State Manager Inspector with Send State Change Event enabled.

Enable State Manager > Send State Change Event when an integration listens for global OnStateChange(GameObject, string, bool). The GameObject path also calls affected owners’ StateWillChange() before applying values and StateChange() afterward. Register/unregister through Events.

StateManager.AddState(GameObject, IStateOwner, State[], State, int) adds a uniquely named non-default State after initialization. Use index 0 for a new name, author other priority positions in the editor, and retain the preset for the owner’s lifetime.