Skip to main content

Transform Mover

NAMESPACEMyDreamGameStudio.InteractAnything
MENU PATHInteraction System > Utilities > Transform Mover
COMPATIBILITYUnity 6.0+
DOC VERSION

An event-driven utility component that translates an object along a single locked local axis. It clamps movement to a specific distance range and supports waypoint events.

Like the Hinge Rotator, this is a mechanical driver. Attach it alongside an Interactable and wire the interactable's output events to the mover's public methods to create sliding doors, drawers, physical buttons, and moving platforms.


Editor Interface​

TRANSFORM MOVERLINEAR MOTIONOBJECT SLIDERMoves an object along a locked local axis supporting toggle transitions, drag deltas, and path waypoints.TARGET & AXIS SETUP✦ Sync Zero RefMover TargetNone (Transform)Move AxisX0Y0Z1Open Distance1TOGGLE MOTION DYNAMICSToggle Speed (Units/s)2DRAG MOTION DYNAMICSDrag Mouse AxisMouse YDrag Sensitivity0.01Drag Speed Limit (Units/s)5SCENE GIZMOS & PREVIEWGizmos (Editor Only — never affects runtime behavior)Show GizmosShow Ghost PreviewsPreview Position (0-1)POSITION PATH EVENTSPath Events (optional)0List is empty+-

Configuration Variables​

Target & Range​

Mover Target
TransformDef: Self
The object that actually moves. If left empty, it defaults to the transform this component is attached to.
Move Axis
Vector3Def: (0,0,1)
The single local axis that movement is locked to. (0,0,1) moves forward/backward along the local Z axis (like a drawer).
Open Distance
floatDef: 1.0
The distance, in world units, from the closed position to the maximum open position. This establishes the absolute physical bounds of the movement.

Toggle Dynamics (On / Off)​

Toggle Speed (Units/s)
floatDef: 2.0
The maximum speed the object will move while animating automatically to the Open (1.0) or Closed (0.0) positions.

Drag Dynamics (Continuous Input)​

Drag Mouse Axis
EnumDef: Mouse Y
Determines if horizontal (X) or vertical (Y) mouse movement drives the position. Use Y for drawers you pull toward you, or X for sliding doors.
Drag Sensitivity
floatDef: 0.01
Units of movement applied per unit of raw mouse delta. Keep this value small compared to rotational sensitivity.
Drag Speed Limit (Units/s)
floatDef: 5.0
Caps how fast the object can slide toward the drag target per second to prevent snapping.

Gizmos & Path Events​

Scene Gizmos & Preview
Editor Controls
Toggle the Scene View debugging elements on or off. The 'Preview Position' slider physically translates the object in Edit Mode for visualization.
Position Path Events
PositionPathEvent[]
Trigger UnityEvents whenever the mover crosses a specific 0-1 point along its path (e.g., play a mechanical 'clack' sound when a drawer is pulled halfway open).

Editor Gizmos & Previewing​

Like the Rotator, the TransformMover provides instant visual feedback via a custom Scene View gizmo.

Closed (0.0)Open (1.0)

WAYPOINT EVENT

LIVE PREVIEW

At the bottom of the inspector, dragging the Preview Position (0-1) slider physically translates the model along its designated axis in your Scene view. A magenta track line connects the Closed and Open ghost previews so you can perfectly align a sliding drawer with a desk frame before hitting Play. If you configure Position Path Events, they will visually appear as markers directly on the movement track.


Wiring Up Interaction Types​

Because this is a pure mechanical utility, you must wire the core Interactable events to this script's public methods.

Toggle (Sliding Doors, Hatches)​

For an object that slides between two extremes:

  1. Set the Interactable type to Toggle.
  2. Wire OnToggleOn to TransformMover.MoveToOpen().
  3. Wire OnToggleOff to TransformMover.MoveToClose().

Drag (Drawers, Heavy Sliding Gates)​

For an object the player must hold and pull:

  1. Set the Interactable type to Drag.
  2. Wire OnDragDelta to TransformMover.MoveByDragDelta(Vector2). The Unity Event signatures match perfectly.
  3. Set your Drag Mouse Axis to Mouse Y for pulling motions, or Mouse X for horizontal sliding.

Push/Pull (Physical Slider Bars, Throttles)​

For an object whose position maps 1:1 with an input value:

  1. Set the Interactable type to Push/Pull (and set its min/max to 0 and 1).
  2. Wire OnValueChanged to TransformMover.SetPosition01(float). The slider will physically track the float value across its defined Open Distance.

The Zero Reference System​

During Awake(), or when Sync Zero Ref is clicked in the Inspector, the Mover captures its current local position and permanently freezes it as the "0.0 Closed" state. The Open Distance is measured entirely relative to this starting point.

If you reposition your desk prefab in the world, the drawers will not break; the zero-reference ensures they always slide perfectly relative to their parent frame.