Skip to content

AttachableObject

An object that can be picked up and placed onto attachment points.

Namespace: Octoputs.Core
Inherits: JungleBehaviour → MonoBehaviour

Overview

AttachableObject is the core component for any GameObject that should participate in the attach/detach lifecycle. It manages its own attachment phase (Idle, Attaching, Attached, Detaching) and runs configurable processes and conditions at each transition. Attach it to any object a player or system should be able to grab and place.

To tag an attachable for filtering, add a Tagger component to the same GameObject and assign Key assets. Then use a GameObjectFilterAttachableCheck with a JungleTagFilter on the receiving slot to enforce matching.

Properties

Property Type Description
pointFilter List<IAttachmentPointCheck> Checks an attachment point must pass for this object to be used with it (added directly — no umbrella wrapper).
transformToAttach Transform The transform that will be attached. Defaults to this object's transform on new components; pick a child to attach a sub-part instead.
attachConditions List<Condition> Conditions that must be met for this object to attach.
attachingState IProcess Process that runs during the attaching phase.
onAttachStarted UnityEvent Invoked when an attach begins.
attachedState IProcess Process that runs while the object is attached.
onAttached UnityEvent Invoked when the object is fully attached.
detachConditions List<Condition> Conditions that must be met for this object to detach.
detachingState IProcess Process that runs during the detaching phase.
onDetachStarted UnityEvent Invoked when a detach begins.
onDetached UnityEvent Invoked when the object is fully detached.

Runtime State

Member Description
IsAttached true while the object is in Attaching, Attached, or Detaching phase.
CurrentAttachmentPoint The point this object is currently bound to (null if Idle).
CurrentPhase Idle / Attaching / Attached / Detaching.
LastDetachedPoint The point this object most recently detached from. Used by the just-detached suppression system.
LastDetachFrame The frame number when the most recent detach completed.
CanBeAttached() Evaluates the attach conditions wired in the Inspector.
CanBeDetached() Evaluates the detach conditions.

Public Methods

Method Description
StartAttach(point, onComplete = null) Begin attaching to point. Runs the configured attaching process, then invokes the callback when phase reaches Attached.
InstantAttach(point) Same effect, skipping the attaching state process.
StartDetach(onComplete = null) Begin detaching from the current point. Runs the detaching process, then invokes the callback when phase returns to Idle.
InstantDetach() Force-complete any in-progress attach/detach to Idle immediately.
PauseAttach() / ResumeAttach() Pause/resume the in-progress attach process.
PauseDetach() / ResumeDetach() Pause/resume the in-progress detach process.
RevertDetach() Cancel an in-progress detach and return to Attached.

For copy-paste C# usage of these members, see Scripting API Examples.

See Also