Skip to main content

Interactable

Interactable controls whether an authored Interactable component participates in native player queries and prompt display.

MethodReturnsDescription
Interactable.SetEnabled(gameObjectId, enabled)booleanEnables or disables the target.
Interactable.IsEnabled(gameObjectId)booleanReads enabled state; missing targets return false.

An Interactable also stores its prompt, exact Lua function name, radius, optional target-specific button, cooldown, repeatable state, and optional Prompt Canvas. An empty Button field inherits the Player Input interaction action. Activation is edge-triggered, so holding the button does not invoke the target every frame.

function Interact(gameObjectId, sourceGameObjectId, context, detail)
if not Interactable.IsEnabled(gameObjectId) then
return
end
Interactable.SetEnabled(gameObjectId, false)
Log.Print("Activated by " .. tostring(sourceGameObjectId))
end

The first two callback arguments are the target and source GameObject IDs. The two strings are diagnostic context and may differ between preview and packaged runtime; do not make gameplay depend on their contents. The Function Name in the Interactable and Interaction Ray must match the custom callback exactly.

Re-enabling a target clears its cooldown and consumed state, allowing a non-repeatable target to be armed deliberately.