DragDetectors [Beta]

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

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