Appearance
Interaction
Interaction separates local target presentation from authoritative validation. InteractAbility scans for candidates, selects one by priority and score, then invokes the target only after distance, angle, availability, and authority checks pass.
Execution model
- Authority — State Authority revalidates and executes the interaction result.
- Prediction — target selection may respond immediately, but authoritative mutation waits for validation.
- Replicated — door state, pickup availability, inventory result, and other target gameplay state.
- Local only — interaction prompt, highlighted target, progress visuals, particles, and audio.
Configure the player
Grant one InteractAbility to the player. Configure:
- scan origin offset;
- interaction radius;
- maximum angle;
- interaction layer mask;
- optional scan interval;
- input target or ability input tag.
The scan uses the actor's World physics query and Fusion lag-compensated hits. Candidates with higher InteractionPriority win; equal-priority candidates are scored by distance and angle.
TargetChanged is appropriate for local prompts and highlights. It does not mean the interaction has been accepted.
Implement an interactable
Derive from Interactable for the built-in transform, priority, text, and authority validation:
csharp
public sealed class Terminal : Interactable
{
[Networked] public bool IsActive { get; private set; }
public override IEnumerator Interact(Actor interactor)
{
if (!ValidateInteractionRequest(interactor))
yield break;
IsActive = !IsActive;
}
}The prefab requires NetworkObject. InteractionTransform controls the measured point, InteractionPriority resolves overlapping candidates, and InteractionText supplies prompt copy.
Implement IInteractable directly when the target cannot derive from Interactable. In that case, perform an equivalent State Authority and availability check before mutation.
Built-in references
Doordemonstrates an authoritative world-state interaction.PickupItemsets replicatedWasPickedUp, invokes its configured event, and optionally despawns its actor.- Compact Showcase inventory pickups demonstrate item creation, capacity failure, timed respawn, and marker visibility.
Present the current target
Subscribe presentation code to InteractAbility.TargetChanged and bind a WorldMarker or local widget to InteractionText. Hide the prompt when the target becomes unavailable. Do not let the prompt itself change the target's network state.
Common failure checks
- No target is selected: check radius, angle, layer mask, collider, and interaction transform.
- Prompt appears but activation fails: confirm
CanInteractstill passes during revalidation. - State changes only locally: ensure
ValidateInteractionRequestpasses on State Authority. - The same object is detected several times: the ability already de-duplicates colliders by interactable.
Try it: Recipe: Inventory Pickup and Recipe: Add a World Marker.
Next: Movement.