DragDetectors [Beta]

Great ideas, I thought about tug of war at first but they’re all good ideas!

3 Likes

I had a question, if you set limits on the DragDetectors are the dragged positions checked server side?

2 Likes

DragDetector derives from ClickDetector so you can just use a DragDetector instead. It’s not a good idea to use both as siblings. Only one will get the events and you can’t be sure which.
But if you disable a DragDetector, it won’t respond to anything, so instead of toggling enabled, you can switch the DragStyle between Physical (which moves your unanchored part with physics) and Custom (which does nothing unless you register a script to do a custom response.

This script watches whether the cursor moves during a drag; if it doesn’t move, then it does your toggle of anchored and a toggle between Custom/Physical. If the cursor does move, and the style is Physical, then your door will rotate.

Here’s the new script:

local door = script.Parent.Parent
local dragD = door.DragDetector

local function changeDoorState()
	door.Anchored = not door.Anchored
	if (dragD.ResponseStyle == Enum.DragDetectorResponseStyle.Physical) then
		dragD.ResponseStyle = Enum.DragDetectorResponseStyle.Custom
	else
		dragD.ResponseStyle = Enum.DragDetectorResponseStyle.Physical
	end
end

local didMove = false

local function dragStart()
	didMove = false	
end

local function dragContinue()
	didMove = true
end

local function dragEnd()
	if (not didMove) then
		changeDoorState()
	end
	didMove = false
end

dragD.DragStart:Connect(dragStart)
dragD.DragContinue:Connect(dragContinue)
dragD.DragEnd:Connect(dragEnd)
2 Likes

I had a question, if you set limits on the DragDetectors are the dragged positions checked server side?

Yes.

1 Like

Thanks!
Understandable, next time I’ll remember!

3 Likes

This really is one of the coolest features that got put out in a while! Thanks alot for sharing this!

2 Likes

I think this is a great feature that will certainly be very useful for a lot of games

Here’s me testing it out in PC, Mobile, and VR

PC:

Mobile:

VR:

also lol you forgot to change this

4 Likes

It inherits from ClickDetector, so the documentation is the same

2 Likes

Wouldn’t that also mean that DragDetectors use the same old code as ClickDetectors or snippets of it?

2 Likes

This looks awesome @PrinceTybalt ! I’ve been waiting for an engine feature like this for a long time! This’ll save a lot of time from having to do custom physic interactions.

Is there a method we can use to initiate/force the DragStart event without player input? Will RestartDrag work for this? For example, I’d like to activate and deactivate a drag with custom functions, tools, etc. Something like :EngageDrag and :DisengageDrag?

3 Likes

Could we see studio play test using a external device soon?

3 Likes

Great addition to Studios, not gonna lie.

6 Likes

Thanks for the response and transparency! :smiley:
Regarding the beginning of my previous statement, how much of an anti-cheat should we keep in our games now that Byfron has released? It’s alright if you don’t know much about it.

2 Likes

This is awesome! im definetly gonna use this. I can already see use cases like

  • rotating items in a shop
  • better puzzles, (just imagine a puzzle where you have to fix a painting on a wall)
  • opening and closing doors
  • throwable weapons

and a lot of other stuff.

Also as some people said here on the comment section i would love to see this also working for guis!, not only screenguis but for surface guis and billboard guis aswell
here are some usecases for screen and surface

  • movable window like interface

  • inventory organization (this is actually a pretty good one)

  • sliders

  • switches
    im sure there’s a lot more.
    now for billboard guis

  • holographic draggable interface, think about tony stark’s table
    1_ZLAxZbUzeqWSIFtapHcvVg

  • literally everything citated before but hologram!

this would be an awesome addition, and im excited to see what’s next in store! thank you.

8 Likes

This is really cool! Was just playing around with it and it works pretty much flawlessly. Is there any plans for this to work with UI too?


there it goes, poor part

3 Likes

Your question has already been asked 3+ times in this thread. In future, remember to search any questions you have up to see if they’ve already been asked & answered before posting them :slightly_smiling_face:

2 Likes

Wow, execution on this was flawless. Great feature!

2 Likes

Awesome!
Congratulations, @PlumbusDude420 you are the first Dev to report back on Touch or VR devices!

In a few places, it looks like you are working against the DragDetectors, like they are not going where you expect. My guess is that you are using TranslatePlane, but you’re trying to move the object in a different plane than it wants to use. We don’t have visual feedback (yet) so it may be hard to tell.
I suspect that you are using TranslatePlane, and your axis is either in X or Z, so your object moves in a vertical plane; but that plane is askance to your point of view.

You could try using TranslateViewPlane, or you could look at the ThrowIt example in “DragDetectors TestWorld 2” to see how you can drag parallel to whichever side you click on.

Also, if you change DragStyle to “BestForDevice” you can experiment with 6DOF movement in VR.

And thanks for the document tip. Since DragDetector derives from ClickDetector, the statement is technically correct. But I will check whether we prefer to substitute the derived class name in documentation situations like this.

3 Likes

Yes! Since DragDetectors inherit from ClickDetector (they are essentially Click-and-drag-detectors), by default they do everything the same. Starting from there, we can add things (like the new dragStart/dragContinue/dragEnd events), change things (like the fact that ClickDetectors lose focus if the cursor stops being over the geometry, but DragDetectors don’t), or keep things (like the fact that DragDetectors still have a MouseClick event, a maxActivationDistance, and a cursorIcon property)

3 Likes

There is not a way to initiate dragStart/dragContinue/dragEnd events without using your cursor.

It’s a rich and interesting topic that we will likely look into. Other users have suggested something like a ProximityPrompt to initiate dragging as well. I’m not clear yet on what the design for this would be like, and there are security issues: we’d need to be careful about so that people don’t just write scripts to move everything around at the wrong time. So it’s not something you can do yet. But it’s on our maybe roadmap.

3 Likes