DragDetectors [Beta]

Hi, I was wondering if there was a way to rotate objects while the mouse is stationary?

Right now, DragDetector:SetDragStyleFunction() is only called when you move the mouse, so my custom rotation variable won’t be put into affect until I move the mouse, which looks very bad and feels unresponsive.

Is there an way to fire the SetDragStyleFunction() after I change my rotation variable? I would’ve thought RestartDrag(), but that causes my object to start going crazy and jittering everywhere.

Rather than using the DragDetector to drag, you could just rotate it while the mouse is down.

[1] set the responseStyle to Custom so it doesn’t do anything when you drag
[2] just listen to dragStart and dragEnd, and run a stepped callback to update the rotation while the mouse us pressed.

Assuming you have your DragDetector below a part or model, and you set ResponseStyle to Custom, this script should do the trick:

local parent = script.Parent
local dd = parent.DragDetector
local steppedConnection = nil
-- change this to move faster or slower
local angularVelocity = 3
-- change this to rotate about a different axis
local rotateAxis = Vector3.new(1,0,0)

dd.DragStart:Connect(function()
	steppedConnection = game:GetService("RunService").Stepped:Connect(function(time, deltaTime)
		parent:PivotTo(parent:GetPivot() * CFrame.fromAxisAngle(rotateAxis, angularVelocity * deltaTime))
	end)
end)

dd.DragEnd:Connect(function()
	if steppedConnection then
		steppedConnection:Disconnect()
		steppedConnection = nil
	end
end)
1 Like

Hey if you want to play with some spongy mechanisms…
Here’s a little plugin I just published.

in the description is a link to a test world, and you should be able to edit that model in studio.

There’s a button to add springs between the parts in the selection, and another to add DragDetectors that let you pull things around in-game.
SpringifyDemo

How can I use the Rotate Axis drag style while setting a rotate number like I can do in studio? (I don’t want it to move smoothly, I want it to snap to a specified value)

Is there any plans to introduce TranslateLineorRotateAxis dragging style? I feel like it would be good in roleplay games where player can move parts and rotate it around.