Detect Object Ability Base
Detect Object Ability Base gives concrete abilities a shared way to find an eligible object before starting. Configure detection on Interact, Pickup, Drive, Ride, Look At, or a supported add-on ability. The base itself is abstract.
Configure object detection
- Add the concrete ability under Ultimate Character Locomotion > Abilities and provide its target-specific components.
- Choose Object Detection and include the target collider layer in Detect Layers.
- Configure optional Object ID, cast geometry, and look-source settings below.
- Test the Inspector’s read-only Detected Object before tuning the concrete action.
| Method | Use and requirements |
|---|---|
| Trigger | Defined proximity area with Is Trigger enabled. Set Max Trigger Object Count for overlapping candidates. Directional cast-angle filtering is separate. |
| Charactercast | Sweeps the character’s collider geometry. Use for full-character reach checks. |
| Raycast | Narrow selection from the configured origin and offset. |
| Spherecast | Wider selection, controlled by Spherecast Radius. |
| Customcast | Derived ability owns detection. |

Object Detection is a mask. Prefer one method unless the concrete ability deliberately combines them. Combined methods try valid trigger candidates first, then Charactercast, Raycast, and Spherecast.
Refine the target and origin
| Setting | Decision |
|---|---|
| Detect Layers | Broad physics filter, required even with an ID. |
| Object ID | Default -1 considers every otherwise eligible object. Otherwise add a matching Object Identifier on the detected object or a parent. |
| Use Look Position | Uses the attached Look Source as a Raycast/Spherecast origin reference; disable for character-relative origin. |
| Use Look Direction | Selects look-source direction independently of origin. |
| Cast Distance / Cast Offset | Reach and local placement for the selected cast. |
| Cast Frame Interval | 0 tests every frame; increase to reduce query frequency. |
| Spherecast Radius | Width of the forgiving cast. |
| Trigger Interaction | Whether Raycast/Spherecast can hit trigger colliders. |
| Angle Threshold | Default 360 imposes no limit. Cast detection can require a more direct approach. |
| Max Trigger Object Count | Capacity for simultaneous valid trigger candidates. |
| Move With Object | Follows the detected Transform while the concrete ability is active, when no other platform relationship owns the character. |
Attach a Look Source before enabling look-position/direction options. Charactercast keeps its origin at the character colliders; its selected reference orients Cast Offset rather than relocating those colliders to the camera. Use Raycast or Spherecast for camera-origin detection.
For casts, Angle Threshold compares detection direction with the hit face. Object Forward Faces on the target or a parent supplies evenly spaced accepted directions instead of one hit normal. For Trigger detection, use concrete-ability facing rules such as Look At’s Field Of View.
Verify selection and lifecycle
Create one valid and one rejected target. Approach or aim at the valid one and confirm Detected Object. Move out of range or turn away; selection should change or clear. Test rejection through layers, ID, facing, and the concrete ability’s required component.
Detection exposes a candidate; input and final ability checks still decide whether it acts. Activate the concrete ability and confirm only that target responds. For Move With Object, move/rotate the target during activity and confirm following ends when the ability stops.
| Symptom | Check | Fix |
|---|---|---|
| Empty detected object | Collider, layer, method, look source | Match the query and target setup. |
| Trigger capacity warning | Overlapping valid triggers | Increase capacity or separate volumes. |
| ID rejected | Layer and parent hierarchy | Match the numeric ID and retain layer eligibility. |
| Detected, action unavailable | Concrete validation or arrival pose | Follow that ability’s guide and Move Towards Location. |
Developer reference
DetectObjectAbilityBase exposes the detection settings and read-only DetectedObject; m_CastFrameInterval is protected. Override ValidateObject(GameObject, RaycastHit?) after the base check. Trigger validation receives a null hit; casts provide the hit used for angle checks. Customcast implementations can use the protected detected-object setter.
The base tracks trigger entry/exit, sends OnObjectDetected when the candidate changes, and manages the moving-object relationship it assigns. Preserve base lifecycle calls in subclasses so candidate and attachment cleanup remain intact.