Die plays an animation-based death response when the character’s Health reaches zero. Use it when the character should choose a directional death animation, remain dead for the respawn delay, and then return through the Character Respawner.
Before you begin
- The character needs Character Attribute Manager, Character Health, and Character Respawner. In Tools > Opsive > Ultimate Character Controller > Character Manager, choose the existing character, enable Health, and select Update Character to add this set.
- In Character Attribute Manager, confirm that the attribute selected by Character Health > Health Attribute exists. The standard setup uses
Health. - The Animator must contain the UCC death states. The included Animator Controller expects Die’s Ability Index Parameter to be
4. - Decide whether this character uses Die or Ragdoll as its primary death response. Do not leave both enabled without intentionally designing their ability priority and transition behavior.
Set up an animated death
- Select the character GameObject.
- In Ultimate Character Locomotion, expand Abilities, select the plus button, and add Die.
- Drag Die near the top of the list, above ordinary movement, interaction, and item abilities. A higher-priority non-concurrent death ability can prevent it from starting.
- Keep Enabled selected, Start Type set to Manual, State set to
Death, and Ability Index Parameter set to4when using the included Animator Controller. Health starts Die through the death event; it is not a player-input ability. - Keep Disable Colliders enabled for the standard animation-based death, or disable it only when the main character colliders must continue participating in the scene while dead.
- Set Camera Rotational Force for the desired camera reaction. The configured vector is multiplied by the magnitude of the killing force.
Adding Health in the Character Manager does not add Die to the ability list. Complete both parts of the setup.
Connect Health and respawning
- In Character Health, select the correct Health Attribute. Assign a Shield Attribute only when damage should consume a separate shield before health.
- Leave Deactivate On Death disabled when Character Respawner should return this character. Character Respawner cannot respawn an inactive character GameObject, and character deactivation cancels its scheduled respawn.
- In Character Respawner, enable Schedule Respawn On Death.
- Choose Positioning Mode:
- None keeps the character at the death position.
- Start Location returns it to the position and rotation recorded when the scene started.
- Spawn Point asks the Spawn Point system for a placement. Use Grouping to restrict which spawn points are eligible;
-1ignores grouping.
- Set Min Respawn Time and Max Respawn Time. The actual delay is selected between those values for each death.
- Enable Check For Obstruction when a character should wait instead of appearing inside another solid object. An obstructed placement is retried after another respawn delay.
- Use Time Invincible After Spawn on Character Health when the character needs a short grace period before it can take damage again.
Choose the death presentation
Directional animations
The built-in Die ability compares the killing position with the character. A position in front selects Ability Int Data 0 (Forward); a position behind selects 1 (Backward). The Animator uses that value to choose the matching branch inside Full Body Layer > Die.
The names describe the built-in animation branches. Test both directions with the character’s actual clips rather than assuming a particular fall direction from the attacker’s location.
Animation or ragdoll
Use Die for an Animator-driven death. Use Ragdoll with Start On Death when the body should be controlled by physics instead. Ragdoll has its own collider, force, layer, and respawn cleanup, so disable the unused death ability unless a custom setup deliberately coordinates both.
Colliders and camera force
With Disable Colliders enabled, Die disables the main colliders registered with Ultimate Character Locomotion and remembers which ones were active. It restores only those colliders when the character respawns. This prevents the animated body from continuing to behave like a live locomotion capsule.
Camera Rotational Force is scaled by the killing force magnitude and sent to the camera through the death response. Reduce the vector when strong impacts rotate the camera too far. A death with zero force produces no scaled rotation.
How it runs
Character Health consumes shield first when one is assigned, then reduces health. When neither attribute has value remaining, it sends the death position, force, and attacker through the OnDeath event.
Ultimate Character Locomotion marks the character as not alive, stops abilities that cannot remain active through death, and clears movement input. Die receives the same event, stores the force and position, selects the directional Ability Int Data, activates the Death state, resets locomotion position and rotation, sends the camera force, and optionally disables the main colliders. Die remains active until respawn.
Character Respawner schedules the return when Schedule Respawn On Death is enabled. At the chosen time it selects the configured position, sends OnWillRespawn, moves the character when required, and sends OnRespawn. Health resets the health and shield attributes and restores the living layer. Die then stops and restores the colliders that it disabled.
Verify in Play Mode
- Keep Ultimate Character Locomotion, Character Health, and Character Respawner visible in the Inspector.
- Apply lethal damage from in front of the character. Confirm the Health value reaches zero, Die shows (Active), the character stops accepting movement, and the Animator reports Ability Index
4with Ability Int Data0. - Repeat from behind and confirm Ability Int Data changes to
1and the other death branch plays. - While dead, confirm the main locomotion colliders match Disable Colliders and that the camera reaction is proportional to the killing force.
- Wait through the configured respawn range. Confirm the character appears at the expected position, Health and Shield reset, Die is no longer active, the original colliders are restored, and movement works again.
- Kill the character a second time to confirm the complete cycle is repeatable. If Check For Obstruction is enabled, block the spawn area and confirm respawn waits until a valid placement is available.
Troubleshoot Die
| Symptom | Check | Fix |
|---|---|---|
| Health reaches zero but Die does not start. | Check that Die is present and enabled, and whether a higher-priority Ragdoll, Revive, or other non-concurrent ability responded to the same death. | Enable the intended death ability, move it above ordinary abilities, and disable competing death responses unless their coordination is intentional. |
| The character dies but no death animation plays. | Check State: Death, Ability Index Parameter: 4, the Animator Controller, and its Die transitions for Ability Int Data 0 and 1. |
Restore the included values and Animator branches, or update both the ability and custom Animator to use the same parameters. |
| The wrong directional animation plays. | Watch Ability Int Data while applying the lethal hit and check the position supplied by the damage source. | Correct the damage hit position or swap the custom Animator branches if the clips are assigned opposite to the intended result. |
| The character never respawns. | Check Schedule Respawn On Death, whether Deactivate On Death disabled the GameObject, and whether Spawn Point can find a placement for the selected Grouping. | Enable death scheduling, keep Character Health from deactivating the character, and provide an eligible unblocked spawn point. |
| The character respawns at the wrong location. | Check Positioning Mode and Grouping. | Use None, Start Location, or Spawn Point for the intended behavior and match the spawn-point grouping. |
| Respawn keeps being delayed. | Check Check For Obstruction and the character’s solid colliders at the requested position. | Clear the spawn volume, choose another spawn point, or disable the obstruction check only when overlaps are acceptable. |
| The character still collides like a live capsule while dead. | Check Disable Colliders on Die and confirm Die, rather than a different death ability, is active. | Enable Disable Colliders or configure the active Ragdoll’s collider workflow. |
| Colliders or Health do not reset. | Check that the respawn path sends OnRespawn instead of only moving or re-enabling the GameObject. |
Respawn through Character Respawner or send the complete UCC respawn lifecycle from the custom system. |
| The camera rotates too far on strong hits. | Compare Camera Rotational Force with the killing force magnitude. | Reduce the configured vector or reduce the force supplied by the damage source. |
Related tasks
- Health configures damage, health and shield attributes, death effects, and post-spawn invincibility.
- Respawner explains respawn timing and positioning modes.
- Spawn Points configures the placements used by Positioning Mode: Spawn Point.
- Ragdoll provides the physics-based alternative to an animated death.
- Revive provides a different return-from-death workflow when the character should recover in place through an ability.
- Abilities explains ability-list priority and concurrent activation.
- Animator Parameters explains Ability Index and Ability Int Data.
Developer reference
Die uses Ability Index Parameter 4. Its Ability Int Data is 0 for the built-in Forward branch and 1 for Backward. The public Force and Position properties contain the values supplied by the death event while the ability is active.
Die listens for OnDeath, sends OnCameraRotationalForce, and stops on OnRespawn. If code starts Die manually, the ability sends OnDeath itself so the rest of the character death lifecycle is notified. In normal gameplay, let Character Health remain the authority that decides when the character is dead.
Add another death animation
Subclass Die and override GetDeathTypeIndex to provide another Ability Int Data value. Replace the built-in Die entry with the subclass so two abilities do not respond to the same death event.
using Opsive.UltimateCharacterController.Character.Abilities;
using UnityEngine;
[System.Serializable]
public class MyDieAbility : Die
{
protected override int GetDeathTypeIndex(Vector3 position, Vector3 force, GameObject attacker)
{
if (force.magnitude > 10f) {
return 3;
}
return base.GetDeathTypeIndex(position, force, attacker);
}
}
In the Animator Controller, add the new state inside Full Body Layer > Die and create a branch whose Ability Int Data condition equals 3. Keep the parent Die transition aligned with Ability Index 4.
