Event Names
Use this reference to match an Ultimate Character Controller event name with the exact callback signature used by the released 3.2.0 runtime. The target object, event name, parameter types, and parameter order must all match the publisher.
Find the correct event and signature
Before registering a callback:
- Find the relevant
EventHandler.ExecuteEventcall in the Ultimate Character Controller or Opsive Shared source. Animator and input callbacks may instead be created by an animation event or anActiveInputEvent. - Note whether the call is object-scoped, such as
ExecuteEvent(character, ...), or global, such asExecuteEvent("OnStateChange", ...). - Copy the event name exactly, including capitalization and any dynamic suffix such as the item slot ID.
- Match the generic parameter types and their order. A fully qualified type and its imported short name are the same type.
- Register and unregister the same delegate on the same target object.
The references below inventory the string event contracts found in the UCC 3.2.0 and Opsive Shared runtime source. Optional integrations can add their own events.
Register and unregister safely
Register while the listener is active and always unregister before the listener is destroyed or pooled. This component listens on the character that owns the UltimateCharacterLocomotion component:
using Opsive.Shared.Events;
using Opsive.UltimateCharacterController.Character.Abilities;
using UnityEngine;
public class AbilityStateListener : MonoBehaviour
{
[SerializeField] private GameObject m_Character;
private void OnEnable()
{
EventHandler.RegisterEvent<Ability, bool>(
m_Character, "OnCharacterAbilityActive", OnAbilityActive);
}
private void OnDisable()
{
EventHandler.UnregisterEvent<Ability, bool>(
m_Character, "OnCharacterAbilityActive", OnAbilityActive);
}
private void OnAbilityActive(Ability ability, bool active)
{
Debug.Log($"{ability.GetType().Name}: {active}");
}
}
Do not replace OnAbilityActive with a new lambda in UnregisterEvent; it would be a different delegate and would leave the original callback registered.
Character and locomotion events
Open the character and locomotion events reference for event names, exact parameter types and runtime uses.
Abilities, items, and inventory events
Open the abilities, items, and inventory events reference for event names, exact parameter types and runtime uses.
Health and attribute events
Open the health and attribute events reference for event names, exact parameter types and runtime uses.
Camera, objects, and impact events
Open the camera, objects, and impact events reference for event names, exact parameter types and runtime uses.
Verify a callback
- Add a temporary log or breakpoint inside the callback.
- Enter Play Mode and trigger the smallest action that publishes the event.
- Confirm the callback fires once and that its values match the observed action.
- Disable or despawn the listener, repeat the action, and confirm it no longer fires.
- Re-enable or respawn the listener and confirm it still fires only once.
For an Animator callback, inspect the animation clip and confirm the animation event name matches exactly. For an input callback, confirm the owning ability or movement type registered its ActiveInputEvent before testing.
Troubleshooting
| Symptom | Check | Fix |
|---|---|---|
| Callback never runs | Compare the object passed to RegisterEvent with the publisher’s first ExecuteEvent argument. |
Register on the same character, camera, Attribute, impacted object, or other owner. Use the targetless overload only for a global event. |
| Callback reports a type mismatch | Compare every generic type and its order with the publisher. | Update both RegisterEvent and UnregisterEvent to the exact signature. |
| Callback runs more than once | Look for repeated registration during enable, pooling, or initialization. | Pair one registration with one unregistration and reuse the same delegate instance. |
| Callback remains after despawn | Check whether the pooled object unregisters before returning to the pool. | Unregister in the listener’s disable or teardown path. |
| Animator callback never runs | Inspect the active animation clip and whether the ability is waiting for an event rather than a duration. | Add or correct the clip event, or configure the supported duration path. |
OnStateChange never runs |
Inspect the scene StateManager. |
Enable Send State Change Event and use a global registration. |
One OnInventoryDropItem signature conflicts with the other |
Check whether both signatures were registered under the same target and name. | Register both with the allowMultipleTypes overload, or listen only to the path you need. |
Match registration and cleanup
Register and unregister the same event name, signature, callback, and target. Use the publisher’s exact spelling and test listeners through activation, deactivation, and pooled reuse.
EventHandler API reference
Opsive.Shared.Events.EventHandler provides object-scoped and global overloads for zero through six parameters:
| Delivery | Register / execute / unregister an integer event |
|---|---|
| Object-scoped | EventHandler.RegisterEvent<int>(target, "MyEvent", callback) / EventHandler.ExecuteEvent<int>(target, "MyEvent", 5) / EventHandler.UnregisterEvent<int>(target, "MyEvent", callback) |
| Global | EventHandler.RegisterEvent<int>("MyEvent", callback) / EventHandler.ExecuteEvent<int>("MyEvent", 5) / EventHandler.UnregisterEvent<int>("MyEvent", callback) |
Here target is the publisher’s object and callback is the same Action<int> delegate at registration and cleanup. See the Events overview for a complete listener.
The event name parameter is a StringHash; string literals convert to it implicitly. The handler stores registrations in static tables and clears them during Unity’s subsystem registration. Use events on Unity’s main thread and unregister normal object and pooled-object listeners explicitly rather than relying on a later domain or subsystem reset.
The one-, two-, and three-parameter registration overloads also accept allowMultipleTypes. Use that option only when the same target and event name intentionally carry more than one signature, such as OnInventoryDropItem.
Related: