DragDetectors [Beta]

Have you added support for dragging in mobile? When I drag it only moves the camera.

3 Likes

It’s probably not supported for Mobile because it’s not supported for Games, so because Mobile can’t access Studio it probably doesn’t have access

4 Likes

At the moment, the feature doesn’t work in-experience, so that means it won’t work for PCs as well. This is going to change when they fully release it though. As far as I am aware, there are properties related to mobile devices in DragDetectors.

4 Likes

Why are DragDetectors and ClickDetectors still using this cursor:
image
and not this one:
image

Also an option to set a key to rotate the object would be kinda nice.

6 Likes

DragDetectors are going to be really good for physics because they make it easy to simulate complex behaviors such as gravity, friction, and collisions.

2 Likes

I might be the only one saying this, but the pixelated one looks better

4 Likes

Possibly, but for consistency sake. I think it should be one or the other.

1 Like

This looks amazing! I can see so many uses, like for use with picking up items and inspecting them, or for tactile switches and stuff. Nice to see that the touch interest code from 2008 is still being used. G3D era stuff!

3 Likes

I have three questions regarding control of physics and network ownership as those can give the client too much control over a model allowing for control over CFrame, Destroy, etc…

Who gets priority over the physics and control of the object being dragged?
Who gets NetworkOwnership of the dragged object?
What were to happen if I were to reset the object’s NetworkOwnership to null while it is being dragged?

Thanks in advance for the answers! :slight_smile:

2 Likes

There’s nothing automatic.
You probably figured this out, but if you want to do script this, you can register two callbacks:
in response to dragStart, save the start DragDetector,.DragFrame
on dragEnd, launch a method that animates you back.
Far from automatic, but at least that’s the only part you have to think about. :slight_smile:

2 Likes

And by “we”, @DeFactoCepti means “I” because they are working on it right now!

3 Likes

i am LITERALLY shaking right now how is this possible

3 Likes

Yes! Touch/mobile is covered!
The problem is, you cannot try it out yet because you cannot use DragDetectors in published games.
However! You can try it in the Roblox Studio simulator:
[1] go to the test ribbon
[2] click ‘Device’
[3] from the dropdown in the main window, choose a touch device
[4] click ‘play’
[5] RESULT: now you are playing with the touch simulator.

You can test out how:
[1] Draggers only work if you are NOT operating the thumbstick, jump button, or other UI elements
[2] When you drag, the camera does not move
[3] There is an indicator circle that shows when you are click-dragging a DragDetector.

Also, something to look forward to: Here is @urukeli 's (who worked a lot on the touch features including multitouch!) demo showing multitouch:


11 Likes

We didn’t bake in all the combinations as options for DragStyle because we didn’t want a really long list. We can always add more if there are certain styles or combinations that people really love. But you can do what you want with a small script.

Here is a script that will let you change between any two DragStyles you like when the modifier key is pressed. Just set the locals ‘keyUpStyle’ and ‘keyDownStyle’ to the ones you want, and place the script as a sibling of the DragDetector. This one translates in a plane and when you hold the key it rotates about the plane’s normal:

local dragDetector = script.Parent.DragDetector

local keyUpStyle = Enum.DragDetectorDragStyle.TranslatePlane
local keyDownStyle = Enum.DragDetectorDragStyle.RotateAxis

local function updateDragStyle(dragDetector, isModifierDown)
	if (isModifierDown) then
		if (dragDetector.DragStyle ~= keyDownStyle) then
			dragDetector.DragStyle = keyDownStyle
			dragDetector:RestartDrag()
		end		
	else
		if (dragDetector.DragStyle ~= keyUpStyle) then
			dragDetector.DragStyle = keyUpStyle
			dragDetector:RestartDrag()
		end
	end
end

dragDetector.DragStart:Connect(function(player, ray, viewFrame, hitFrame, clickedPart, vrInputFrame, isModifierDown)
	updateDragStyle(dragDetector, isModifierDown)
end)

dragDetector.DragContinue:Connect(function(player, ray, viewFrame, vrInputFrame, isModifierDown)
	updateDragStyle(dragDetector, isModifierDown)
end)
6 Likes

Hello!
I just had time to try these, and they’re very useful, but I found 2 things that could be made better, I might add things, so first:
You cannot use it with a ClickDetector, probably this isn’t something that’s meant to be, but probably is just a “error” and second it can pass trough anchored parts, if I simply put my cursor on a part it’ll pass trough it, maybe there could be a setting like PassTrough which would allow it to pass trough (maybe with CollisionGroups)

2 Likes

Hi @mohammed1336,

Great questions!
Here’s how it works: The server shoots the rays into the scene and decides what to do,. If it uses physics to move a part, it adds a constraint… which replicates to all players. Then it edits the target position of that constraint… which replicates to all players.
So, whoever has network ownership will do the physics and the physics system will propagate the PV (position/velocity info) to all other players and the server, regardless of who has that ownership.
This continues to work even if network ownership changes (although you will see a hiccup in motion as the adjustment is made)
And then when it’s done, the server removes the constarint… which replicates to all players.

Note that TODAY that constaint is an instance that you can see in the explorer. This will almost certainly change to use internal constraint methods prior to our final release, so that we are not adding/removing instances during a drag

5 Likes

Wait, does this mean it’ll not work when multiple Players will try to drag it at the same time?
I also like how you explain how you create these things basically telling us how to make it ourselves :sweat_smile:

2 Likes

Hi @Dede_4242,

First, I’d like to understand what you are trying to do with ClickDetector that’s not working. Can you explain more fully what you tried to do? Maybe there is a way to do it if you tell me more.
DragDetectors are actually derived from ClickDetector, but they are separate things. You would use one or the other.

Second, regarding moving anchored parts through other things: yes others have suggested they’d like this as well. It’s not an easy fit with the way our physics engine works, but we may be able to find a way.

2 Likes
  1. I was basically trying to make a door which you would click and it would unanchor, after you could drag it with the DragDetector, I already tried to disable/enable it but it won’t work anyway, if you want the script:
local door = script.Parent.Parent
local clickD = script.Parent
local dragD = door.DragDetector

local function onClick()
    door.Anchored = not door.Anchored
    dragD.Enabled = not door.Anchored
end

clickD.MouseClick:Connect(onClick) --or what event it was called I don’t remember
  1. You mean making it pass trough parts or adding the toggle?
3 Likes

Any one DragDetector can not be dragged by two players (or fingers) at the same time. Whoever clicks first “owns” the drag until they let go.
We may add an option to change this in the future. It could be really cool if two people clicking opposite ends of something could either move by pushing in the same direction, or spin it by pushing in opposite directions. Teamwork! Or you could use two fingers on touch on the same item to move it, twirl it, etc.

5 Likes