Hinge Rotator
An event-driven utility component that rotates a transform around a single locked local axis. It clamps rotation to a specific min/max range and supports optional "locked" snap angles (detents).
This is not an interactor itself; it is a mechanical driver. You attach this alongside an Interactable and wire the interactable's output events directly to the rotator's public methods to create doors, levers, dials, and wheels.
Editor Interface
Configuration Variables
Target & Range
Toggle Dynamics (On / Off)
Drag Dynamics (Continuous Input)
Advanced Features
Editor Gizmos & Previewing
The HingeRotator features heavy Scene-view integration to make setup visual rather than mathematical.
At the bottom of the inspector, you will find the Preview Angle (0-1) scrubber. In Edit Mode (not just Play mode), dragging this slider will physically rotate the model in your Scene view so you can verify your Min, Max, Open, and Closed states exactly as they will look in-game.
When the object is selected in the Scene View, a custom magenta rotation arc is drawn matching your Min/Max bounds, along with ghost-mesh previews of where the object will end up at its extremes. If you configure Angle Waypoints, they will visually appear as markers on the rotation arc.
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 (Doors, Latches)
For an object that flips between two states:
- Set the Interactable type to Toggle.
- Wire
OnToggleOntoHingeRotator.RotateToOpen(). - Wire
OnToggleOfftoHingeRotator.RotateToClose(). - Ensure your Rotate Speed (°/s) is set high enough so the door doesn't feel sluggish.
Drag (Heavy Valves, Free-swinging Doors)
For an object the player must hold and manually swing:
- Set the Interactable type to Drag.
- Wire
OnDragDeltatoHingeRotator.RotateByDragDelta(Vector2). The Unity Event signatures match perfectly, so no adapter is needed. - Set your Drag Mouse Axis to
Mouse Xfor horizontal swings (doors) orMouse Yfor vertical pulls (levers). - If you want the door to snap into a lock groove when let go, enable Use Locked Angles on the Rotator and wire the Interactable's
OnInteractionCompletetoSnapToNearestLockedAngle().
Push/Pull (Joysticks, Steering Wheels)
For an object that returns to a specific point when released:
- Set the Interactable type to Push/Pull (and set its min/max to
0and1). - Wire
OnValueChangedtoHingeRotator.SetAngle01(float). The float value will directly interpolate the hinge between itsMin AngleandMax Angleinstantly (since Push/Pull handles its own input smoothing).
The Zero Reference System
During Awake(), or when Sync Zero Ref is clicked in the Inspector, the Rotator captures its current local rotation and permanently freezes it as "0 degrees". All subsequent Min, Max, Open, and Closed angles are measured relatively from this starting snapshot.
If you reposition a door frame in the scene and the door is now physically open by default, simply click the Sync Zero Ref button at the top of the Inspector to bake the new pose as the zero-baseline.