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.
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
You mean making it pass trough parts or adding the toggle?
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.
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)
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?
Thanks for the response and transparency!
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.
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
literally everything citated before but hologram!
this would be an awesome addition, and im excited to see what’s next in store! thank you.
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