The Revive ability will play a getting back up animation transitioning from the character laying on the ground. The ability can start when the character dies or be triggered by the player/environment. If the ability starts when the character dies then a delay is used which will prevent the ability from playing until the timer has elapsed. The revive ability includes a forward and backwards revive animation but the ability can easily be extended for other revive types.

Setup

  1. Select the + button in the ability list under the “Abilities” foldout of the Ultimate Character Locomotion component.
  2. Add the Revive ability. This ability should be positioned near the top of the list so it will override any abilities beneath it.
  3. Determine if the ability should start when the character dies. This is enabled by default with the Start On Death toggle.

Adding New Revive Animations

There are two steps required in order to add new revive animations:

  1. The ability needs to detect which animation should be played.
  2. The Animator Controller needs to have the new animations added to it.
Ability

When adding new functionality we recommend subclassing the abilities so it’s easier to update when a new version of the Ultimate Character Controller is released. For this situation you’ll want to subclass the Revive ability:

using Opsive.UltimateCharacterController.Character.Abilities;
    
public class MyReviveAbility : Revive
{

}

When the ability starts it will call GetReviveTypeIndex to determine the AbilityIntData Animator parameter value. Your custom revive ability should override this method and return a new value. In this example we will return a value of 3 if the attacker has the tag Human.

Opsive.UltimateCharacterController.Character.Abilities;

public class MyReviveAbility : Revive
{
    /// <summary>
    /// Returns the value that the AbilityIntData parameter should be set to.
    /// </summary>
    /// <param name="position">The position of the force.</param>
    /// <param name="force">The amount of force which killed the character.</param>
    /// <param name="attacker">The GameObject that killed the character.</param>
    /// <returns>The value that the AbilityIntData parameter should be set to.</returns>
    protected override int GetReviveTypeIndex(Vector3 position, Vector3 force, GameObject attacker)
    {
        if (string.Compare(attacker.tag, "Human") == 0) {
            return 3;
        }
        return base.GetReviveTypeIndex();
    }
}
Animator

Now that the custom ability has been created it’s time to modify the Animator Controller so the revive animation with a type of 3 can play. This can be done by creating a new state within the Full Body Layer -> Revive substate and transitioning to it when the AbilityIntData parameter value is equal to 3:

Inspected Fields

Start On Death

Should the ability start when the character dies?

Death Start Delay

Specifies the number of seconds after the character dies that the ability should start.