Skip to main content

Class Interactable

World object that the player can interact with, exposing up to OPTIONS_COUNT_MAX labelled choices and gating interaction on proximity and on-screen visibility.

public class Interactable : MonoBehaviour

Inheritance​

Remarks​

The design separates what can be interacted with (this component's options) from who is near it (InteractionArea + Interactor). This means the same Interactable can work with different interaction ranges per object without changing the options — the area size in the Inspector controls range.

Visibility gating (via visibilityColliders) prevents the interaction UI from appearing when the object is behind the player or occluded — participants can only interact with what they can actually see.

Options are hard capped at four (OPTIONS_COUNT_MAX) to match the maximum number of on-screen input prompts the UI can display simultaneously.

Fields​

options​

Array of available interaction options for this interactable.

[Header("INTERACTABLE OPTIONS")]
[Tooltip("List of interaction options available for this object (maximum 4).")]
public InteractableOption[] options

Field Value​

InteractableOption[]

Remarks​

These options are presented when the interactor can interact with the interactable. Each interactable can have a maximum of 4 options.

Properties​

HasVisibilityBounds​

Returns true if any visibility colliders are assigned.

public bool HasVisibilityBounds { get; }

Property Value​

bool

Identifier​

Get interactable's identifier.

public string Identifier { get; }

Property Value​

string

IsInteractable​

Returns true if there are any interaction options available to interact.

public bool IsInteractable { get; }

Property Value​

bool

VisibilityBounds​

Get the combined bounds of all visibility colliders.

public Bounds VisibilityBounds { get; }

Property Value​

Bounds

Methods​

GetInteractionDuration(int)​

Gets the interaction duration for the given option index.

public float GetInteractionDuration(int index)

Parameters​

NameTypeDescription
indexintIndex of the interaction option.

Returns​

float — Duration of the interaction, or 0 if unavailable.

InvokeInteractionCancel(int)​

Triggers the interaction cancel event for the given option index.

public void InvokeInteractionCancel(int index)

Parameters​

NameTypeDescription
indexintIndex of the interaction option.

InvokeInteractionComplete(int)​

Triggers the interaction complete event for the given option index.

public void InvokeInteractionComplete(int index)

Parameters​

NameTypeDescription
indexintIndex of the interaction option.

InvokeInteractionStart(int)​

Triggers the interaction start event for the given option index.

public void InvokeInteractionStart(int index)

Parameters​

NameTypeDescription
indexintIndex of the interaction option.

InvokeInteractionUpdate(int)​

Triggers the interaction update event for the given option index.

public void InvokeInteractionUpdate(int index)

Parameters​

NameTypeDescription
indexintIndex of the interaction option.

IsInteractionAutoComplete(int)​

Returns whether the interaction should auto-complete for the given option index.

public bool IsInteractionAutoComplete(int index)

Parameters​

NameTypeDescription
indexintIndex of the interaction option.

Returns​

bool — True if auto-complete is enabled, false otherwise.

TryGetOption(int, out InteractableOption)​

Retrieve the interaction option by the given index, if it exist.

public bool TryGetOption(int index, out InteractableOption option)

Parameters​

NameTypeDescription
indexintIndex of the interaction option.
optionInteractableOptionThe output argument that will contain the retriveved option or default.

Returns​

bool — Return true if the option was retrieved, false otherwise.

OptionsChanged​

Raised whenever options is replaced, so observers can refresh anything derived from the option list.

public event Action OptionsChanged

Event Type​

Action

Remarks​

Completion policies such as ConsumeSelf mutate the option array while the interactable remains active. Without this notification the interaction UI would keep displaying prompts for options that no longer exist.

  • Remarks
  • Fields
    • options
  • Properties
    • HasVisibilityBounds
    • Identifier
    • IsInteractable
    • VisibilityBounds
  • Methods
    • GetInteractionDuration(int)
    • InvokeInteractionCancel(int)
    • InvokeInteractionComplete(int)
    • InvokeInteractionStart(int)
    • InvokeInteractionUpdate(int)
    • IsInteractionAutoComplete(int)
    • TryGetOption(int, out InteractableOption)
    • OptionsChanged