Object Identifier gives a GameObject a numeric role within a searched hierarchy or a Detect Object filter. Use direct references for fixed objects when supported, and IDs for reusable items or interchangeable models that expose equivalent attachment roles.

Create a project role

  1. Create a map through Assets > Create > Opsive > Ultimate Character Controller > Utility > NameIDMap and keep it in a project-owned folder.
  2. Open Tools > Opsive > Ultimate Character Controller > Utility > Object Identifiers. Assign that asset to Name Map.
  3. Add Object Identifier to the target GameObject. Open the dropdown beside ID, enter a descriptive name such as Rifle Spawn Parent, and select Add.
  4. Save the editable CSV when requested. Version both the map and CSV so the team shares names and numbers.
  5. Select the role on the marker and choose the same ID in the consuming field or ability. Clear an old direct reference when configuring an ID-based field, following that feature’s ownership rules.
  6. Save the scene/prefab. Repeat the same role on the equivalent object in each alternative character model.

The dropdown supports existing entries, Add, and Open Editor. Order By offers ID Ascending, ID Descending, Name Ascending, and Name Descending. Names and IDs must be unique in the map; sorting affects presentation. Runtime matching uses the serialized number, while names help authors select it.

Object Identifier Inspector with ID 106 assigned to the selected GameObject

The legacy image shows ID 106. For new project roles, use generated IDs starting at 10000, reserving lower values for demo content. Keep shared role IDs no larger than 2147483647 so signed consuming fields can represent them.

Match the consumer and hierarchy

Consumer Marker placement and configuration
An IDObject<Transform> attachment Put the marker on the intended Transform, within the parent/child hierarchy supplied by the feature.
An IDObject<T> for another component Put component T beside the marker on the same GameObject. Check the resolved object for null.
Runtime item Spawn Parent / Holster Target Place one matching role in each model’s searched hierarchy or Item Slot. Follow Third Person Perspective for its ID-driven lookup.
Detect Object ability Put the marker on the detected object or a parent and match the ability’s Object ID. Keep the physics and ability-specific requirements valid.
Scene-wide, save, or network identity Use the corresponding project registry or save/network integration.

Keep exactly one marker for a role within each active searched hierarchy. Reuse that ID across alternative models when their equivalent attachment points serve the same role. Hierarchy searches include inactive objects and disabled marker components; change the hierarchy/ID and invalidate the consumer when changing availability.

The marker’s ID defaults to 0. IDObjectBase.ID and Detect Object > Object ID default to -1, meaning no ID lookup or no ID filter respectively. Select positive project IDs through the map instead of entering negative marker values manually.

Model changes and cached references

An IDObject<T> can use a direct object or cache a hierarchy result. In project code, call ResetValue() when the searched root, marker, required component, ID, or model changes, then resolve against the new root and check the returned object. Invalidate before a fresh search even when requesting forceSearch.

This existing resolver example exposes that lifecycle through Invalidate() and Resolve(). Call Invalidate() before resolving a changed hierarchy; pass the intended model root and handle a null result:

using Opsive.UltimateCharacterController.Objects;
using UnityEngine;

public class ModelAttachmentResolver : MonoBehaviour
{
    [SerializeField] private IDObject<Transform> m_Attachment = new IDObject<Transform>();

    public Transform Resolve(GameObject modelRoot, bool hierarchyChanged)
    {
        return m_Attachment.GetObjectInChildren(modelRoot, hierarchyChanged);
    }

    public void Invalidate()
    {
        m_Attachment.ResetValue();
    }
}

Set a new ID before invalidating and resolving. For an intentionally direct runtime reference, BaseObject selects the direct-reference path and resets the ID to -1. Use ResetValue() when returning to hierarchy resolution. Keep each owning feature’s required ID search policy; some model-specific item paths deliberately force lookup.

Detection remains a separate filter

For abilities derived from Detect Object Ability Base, Detect Layers, collider/trigger setup, range, angle, and the concrete target component determine eligible physics candidates. Object ID then narrows them to a matching marker on the object or its parents. Leave Object ID -1 for the unfiltered ID policy. See Detect Object Ability Base.

Verify the role

  1. Equip/unequip the item or trigger the consuming feature. Confirm the resolved spawn/holster/component belongs to the intended hierarchy.
  2. Switch to every supported model and repeat. Check equivalent roles and one matching marker in each model.
  3. Change/remove a marker or spawn its replacement. Invalidate the consumer, resolve again, and check both a valid result and the intended missing-target fallback. Repeat after an earlier unsuccessful lookup.
  4. For detection, compare a matching-ID target, another ID, and an excluded physics layer. Only candidates satisfying every filter should become Detected Object.
  5. Reopen the project map after a clean checkout and confirm that its CSV-backed names and generated IDs remain available to other authors.

Serialize role configuration with the scene/prefab and map assets. Rebuild runtime references and caches after loading or model replacement, using the save/network system’s own stable object identity where required. Model Switch, Item Creation, and the perspective setup cover adjoining item/model ownership.