DragDetector
The DragDetector instance facilitates and encourages interaction with 3D objects in an experience, such as opening doors and drawers, sliding a part around, and much more. Key features include:
Place a DragDetector under any BasePart or Model to make it draggable via all inputs (mouse, touch, gamepad, and VR), all without a single line of code.
Choose from several DragStyle options, define how the object responds to motion via ResponseStyle, and optionally apply axis or movement limits.
Scripts can respond to manipulation of dragged objects to drive UI or make logical decisions, such as adjusting the light level in a room based on a sliding wall switch dimmer.
Players can manipulate anchored parts or models and they'll stay exactly where you put them upon release.
DragDetectors work in Studio as long as you're not using the Select, Move, Scale, or Rotate tools, making it easier to test and adjust draggable objects while editing.
See the 3D Drag Detectors guide for details and usage examples.
Summary
Properties
Sets the cursor icon to display when the mouse is activated over the parent of this DragDetector.
Whether constraint force is applied to the object's center of mass.
The primary axis of motion, expressed relative to the reference frame.
The CFrame of the pivot, dependent on the drag detector's ReferenceInstance.
The paradigm used to generate proposed motion.
Whether the DragDetector responds to user input.
During gamepad input, the modifier Enum.KeyCode for the secondary mode of motion.
During keyboard input, the modifier Enum.KeyCode for the secondary mode of motion.
Along with MinDragAngle, impedes the drag detector's attempts to generate motion.
Along with MinDragTranslation, impedes the drag detector's attempts to generate motion.
Maximum force applied for the object to reach its goal.
Maximum torque applied for the object to reach its goal.
Along with MaxDragAngle, impedes the drag detector's attempts to generate motion.
Along with MaxDragTranslation, impedes the drag detector's attempts to generate motion.
Specifies the YXZ rotation of axes of motion relative to the reference frame.
Controls the permission level for which players can interact with the DragDetector.
An instance whose CFrame is the reference frame for the drag detector.
The paradigm used to move, or not move, the objects affected by the drag detector.
Higher values cause the object to reach its goal more rapidly.
Whether user input on a DragDetector replicates to the server or remains local to the specific client.
The secondary axis of the motion.
If DragStyle is Enum.DragDetectorDragStyle.RotateTrackball, multiplier for adding a radial pull rotation as a contribution to the total.
If DragStyle is Enum.DragDetectorDragStyle.RotateTrackball, multiplier for adding roll rotation to the total.
During VR input, the modifier Enum.KeyCode for the secondary mode of motion.
The Axis expressed in world space.
The SecondaryAxis expressed in world space.
Properties
Sets the cursor icon to display when the mouse is hovered over the parent of this ClickDetector or DragDetector.
Maximum distance between a character and the ClickDetector or DragDetector for the player to be able to interact with it.
Methods
Adds a function to modify or constrain proposed motion.
Returns the reference CFrame in which motion is expressed.
May be invoked from a script to restart the drag using new parameters.
Passes a function to be used if and only if DragStyle is set to Enum.DragDetectorDragStyle.Scriptable.
Passes a function to be used if and only if PermissionPolicy is set to Enum.DragDetectorPermissionPolicy.Scriptable.
Events
- DragContinue(playerWhoDragged : Player,cursorRay : Ray,viewFrame : CFrame,vrInputFrame : OptionalCoordinateFrame,isModeSwitchKeyDown : boolean):RBXScriptSignal
Fires when a user continues dragging the object after DragStart has been initiated.
Fires when a user stops dragging the object.
Fires when a user starts dragging the object.
Events
Fires when a player interacts with the parent of a ClickDetector or DragDetector.
Fires when the parent of a ClickDetector or DragDetector is hovered over by a player.
Fires when a player's cursor hovers off the parent of a ClickDetector or DragDetector.
Fires when a player right clicks their mouse cursor on a ClickDetector or DragDetector.