Skip to main content

Interactable Target

NAMESPACEMyDreamGameStudio.InteractAnything
MENU PATHInteraction System > Core > Interactable
COMPATIBILITYUnity 6.0+
DOC VERSION

The Interactable is the central, object-side brain of the interaction system. It defines how an object behaves when a player targets it, manages timing and state changes, and dispatches UnityEvents to mechanical utilities or your custom logic.

Because it handles no raycasting or input polling itself, it maintains zero Update() overhead until actively engaged by an Interactor.


Dynamic Behavior Configurations​

The specific settings and output events of an Interactable change entirely based on the chosen Interaction Type. Select a type below to view its specific Inspector UI, parameters, and events.

Fires immediately upon a single button press. Best for simple light switches, item pickups, and basic triggers.

INTERACTABLE TARGETCORE LOGICSTATE / EVENTSCentral target handling interaction input, state changes, cooldowns, and event dispatching.INTERACTION TYPE & STATEInteraction TypeInstantInteraction EnabledCooldown (Seconds)0.5SPATIAL ANCHORS & POINTS✦ Set As PointsInteraction PointNone (Transform)UI Prompt AnchorNone (Transform)CONTEXTUAL PROMPTSDefault PromptinteractFOCUS & HOVER EVENTSOn Focus Enter ()List is emptyOn Focus Exit ()List is emptyINTERACTION LIFECYCLE EVENTSOn Interaction Start ()List is emptyOn Interaction Complete ()List is emptyOn Interaction Cancel ()

Type-Specific Implementation

The Instant type utilizes standard lifecycle events natively and requires no unique mechanical setup.


Global Properties​

These variables and events are shared across all interaction types and dictate the foundational behavior of the object in the world.

Core State & Cooldowns​

Interaction Enabled
boolDef: True
Master kill-switch. Uncheck to temporarily disable interactions via script or event without destroying the component.
Cooldown (Seconds)
floatDef: 0.5
Minimum time between completed interactions. Critical for preventing animation clipping or logic spam if a player rapidly clicks a switch.

Spatial Anchors & Points​

Interaction Point
TransformDef: Self
The physical origin point for distance and line-of-sight checks. Useful if your collider is massive, but you only want the player to interact from a specific control panel.
UI Prompt Anchor
TransformDef: Self
Where 3D world-space prompts or examine panels should spawn relative to this object.

Contextual Prompts​

The string text fed to the UI. The system automatically reads the correct prompt based on the object's current state.

Default Prompt
stringDef: interact
The standard fallback text used for Instant, Push/Pull, and Drag types.
Prompt When 'Off' / 'On'
string
Overrides the default prompt strictly based on the internal boolean state of a Toggle or Hold+Toggle interactable.
Prompt While Holding
string
Shown while actively holding, before completion (Hold/Hold+Toggle only). Leave empty to keep showing the normal prompt while holding.

Lifecycle Events​

On Focus Enter ()
UnityEvent
Fires the moment the player's crosshair/raycast targets this object. Use this to trigger outline shaders or crosshair changes.
On Focus Exit ()
UnityEvent
Fires when the player looks away. Use this to disable outlines.
On Interaction Start ()
UnityEvent
Fires on the exact frame the input button is initially depressed.
On Interaction Complete ()
UnityEvent
Fires when the mechanic resolves successfully (e.g., the instant click registers or the hold duration completes).
On Interaction Cancel ()
UnityEvent
Fires if the interaction is forcefully interrupted by logic.

Scripting API​

You can easily interface with the core Interactable state via C# to drive game logic or override behaviors programmatically.

using MyDreamGameStudio.InteractAnything;
using UnityEngine;

public class CustomTriggerLogic : MonoBehaviour
{
private Interactable interactable;

private void Awake()
{
interactable = GetComponent<Interactable>();

// Listen for standard completion
interactable.OnInteractionComplete.AddListener(HandleInteraction);
}

private void HandleInteraction()
{
Debug.Log("Object was interacted with!");
}

// Example of disabling the object programmatically
public void LockObject()
{
interactable.SetEnabled(false);
}
}