The Aim item ability will place the character in an aiming state. Generally while the character is in a first person perspective you don’t have to press a button in order to aim so the ability can automatically activate while in a first person perspective.

Always Aim

If you’d like your character to always aim set the Start Type to Automatic and the Stop Type to Manual. This will keep the Aim ability active all of the time.

Events

When the item ability starts aiming it will send the “OnAimAbilityStart” event using the built-in Event System. This event has two parameters: the first indicates if the ability started, and the second indicates if the ability is being started from input. The input start parameter will be false when the ability is automatically starting while in a first person perspective. You can register and use this event with:

using UnityEngine;
using Opsive.UltimateCharacterController.Events;

public class MyObject : MonoBehaviour
{
    public void Awake()
    {
        EventHandler.RegisterEvent<bool, bool>(gameObject, "OnAimAbilityStart", OnAim);
    }

    /// <summary>
    /// The Aim ability has started or stopped.
    /// </summary>
    /// <param name="start">Has the Aim ability started?</param>
    /// <param name="inputStart">Was the ability started from input?</param>
    private void OnAim(bool aim, bool inputStart)
    {
        // Ignore the event if the aim ability wasn't explicitly started.
        if (!inputStart) {
            return;
        }
        Debug.Log("Aim ability start: " aim};
    }

    /// <summary>
    /// The GameObject has been destroyed.
    /// </summary>
    public void OnDestroy()
    {
        EventHandler.UnregisterEvent<bool, bool>(gameObject, "OnAimAbilityStart", OnAim);
    }
}

Inspected Fields

Stop Speed Change

When the Aim ability is activated should it stop the speed change ability?

Activate In First Person

Should the ability activate when the first person perspective is enabled?