Interactable
Interactable controls whether an authored Interactable component participates
in native player queries and prompt display.
Put Interaction Ray on the entity that aims at the target, and Interactable with a Lua Behaviour on the target. The ray works with a Lua-controlled player or a separate camera entity in both Play Mode and PS1 builds; Player Motor, First Person Controller and Third Person Controller are not required. Player Input is optional: without it, the inherited button is Cross. If Player Input is present but disabled, the ray cannot activate targets. Pausing gameplay or a timeline that disables player controls also blocks native activation.
If your Lua script already detects targets and calls GameObject.Invoke, as
Last Exit does, do not add an Interaction Ray for the same action: use one
interaction path to avoid activating an object twice.
For dialogue controls, see Locking the player and camera during dialogue, with examples for native controllers and Lua scripts.
| Method | Returns | Description |
|---|---|---|
Interactable.SetEnabled(gameObjectId, enabled) | boolean | Enables or disables the target. |
Interactable.IsEnabled(gameObjectId) | boolean | Reads 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.
Configure Button, Cooldown (s), Repeatable, and Prompt Canvas
on the object's Interactable component. With Built-in Text Prompt
selected, the engine displays button: prompt at the bottom of the screen
when a target is reachable. No separate UI element or Lua drawing call is
needed. A named Prompt Canvas replaces that text; keep the canvas and its
elements enabled so the interaction system can show and hide it.
The same query controls prompt visibility and activation in Play Mode and PS1. Distance measures from the Interaction Ray entity's world position to the target's world position, extended by the target's Radius. In Ray mode, the source's yaw sets the aiming direction and the larger of the ray and target radii provides horizontal tolerance. Sphere mode also accepts targets beside or behind the source. Require Line Of Sight rejects blocked targets in either mode. Disabled targets and consumed non-repeatable targets do not display a prompt.
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.