Announcing DragDetectors!

BTW You want cool new button actions?
Here’s some info info I sent to a user in our old beta posting:

You can actually make some cool variations on buttons using DragDetectors that you were never able to do with clickDetectors, because you can detect both the down and the up on dragStart and dragEnd.
If you set the ResponseStyle to custom, and then don’t do anything, then the part won’t move but you can still detect down and up.

There are 3 button examples in DragDetectors TestWorld 2
A push button, a sprarying button , and a toggle button:
ThreeButtons

6 Likes

@paper_hat Can you post a video or link showing exactly what you are doing so I can see what’s happening? (Also uninstall and reinstall first, if you have not already?)

2 Likes

@strawbberrys
I’m curious what your end goal is for the interaction you want in your game. Care to share?

And I did some experiments.
I created a rig with RigBuilder.
I found that whether you place the DragDetector under the model, the HumanoidRootPart, or any of the body part meshes, you’d get the same result. You move the whole body.

But then if you place that model under StartPlayer and name it StarterCharacter, then the DragDetectors have no effect when you run the game using the rig as an active player.
It might be reasonable to expect this to work; but there may be a conflict with all the player scripts that control how it moves and animates.

I need to talk to some other people to determine whether this is really a bug or if the player scripts would be expected to prevent the dragging. I dont’ see a cursor change though, which is a bad sign.

3 Likes

@strawbberrys well this is interesting.
You can drag other players, just not yourself! And when you do it they respond by animating to walk where you drag them
There is specific code in our ClickDetectors and DragDetectors to prevent clicking on your own players avatar. It was added to fix a bug that was reported.

Is it important to be able to drag yourself and not others?

DragOthersNotYourself

5 Likes

Super cool! I’m questioning reality after this.

4 Likes

Here are two short videos I created during the beta. We’ll add them to the list up top soon too:

How To Create A Sliding Door With DragDetectors
ShortSlidingDoor

How To Create A DragDetector that Only One Player Can Operate

9 Likes

@PrinceTybalt Thank you for your reply. DragDetector is also off the beta list in my Studio.
And in this way, DragDetecotor is indeed ready to be added from the explorer, and it works when I publish the space. However, only Roblox Studio test play does not work. In Roblox Studio, the Drag “hand” icon appears like this, but the object cannot be moved. This is the same phenomenon even if I bring the test space you introduced above to my Studio.
スクリーンショット 2023-10-13 8.16.55
スクリーンショット 2023-10-13 8.16.48

2 Likes

Hmm. The hand icon is correct for DragDetectors, so the DragDetector code is getting called.
Check the output window. Do you see anything printed?
If not, try adding print statements into the dragStart, dragContinue, and SetDragStyleFunction to see if hey get called.

What about the green one, which uses geometric style motion and no constraints?

And Can you use a simple DragDetector case?
Try doing just this:
[1] add a part
[2] set it anchored
[3] add a DragDetector below it
[4] hit play.
Can you drag that one?

3 Likes

I get that is possible with scripting, it just seems like it would be a logical property of the draggers , considering even the tools in studio can snap movement and rotation.

Thought I would mention it, considering almost every ‘move part’ script I have ever made, needed some sort of snapping.

3 Likes

@PrinceTybalt As you said, I tried to attach an anchor to the Part and tried installing DragDetector.
But it didn’t work in my Studio. When I published it, it worked in the published version.
The one below is the public version.That’s the gray part.

I checked the output, but no particular errors occurred.
Regarding print, I don’t know enough about programming and didn’t know how to do it.


スクリーンショット 2023-10-13 9.35.26

2 Likes

Those messages in your output may have something to do with the problem. I don’t see those on a normal installation of Roblox Studio, and they are not produced by my scripts.

In particular the “hotFix” output is strange.,
“Stored Mouse” is especially concerning since it’s happening on the client (hooray for katakana) and the mouse is the input that DragDetectors care about.

Maybe you have some kind of plugin installed? Try disabling all your extra plugins and restart studio?
Maybe reinstall studio entirely if that does not work?

3 Likes

Hello devs. I would like to share with you the game we have been working on for a while now inspired almost entirely by Drag. I hope you like it and I congratulate you for the good work of these interesting new functions.

(14) Drag Dentist Obby! (Drag Obby) (NEW) - Roblox

7 Likes

OMG this is totally awesome. You are coming up with new obby elements that I hope will become classics.
One suggestion: The blocks that you toss around might be easier to work with if you steal the script behavior from the “Throw It!” demo in DragDetectors TestWorld 2. If you use that, then the plane that you drag the block in will always match the plane you click on.

5 Likes

Oh thank you very much for your words! And thanks for the tip too I’m trying it right now :slight_smile:

5 Likes

@PrinceTybalt I see, it seems like the Coaster Tool Plugin is involved. When I turned off the plugin, DragDetector worked in Roblox Studio as well. When testing DragDetector, turn off this plugin. thank you very much. Thank you very much for helping me.

2 Likes

I’m curious if you could implement the system you use in the ‘Lift and Carry’ game into the drag controller, so it’s more easily accessible rather than having 150 lines of code for one draggable item.

2 Likes

@Sho_Takahashi That’s great news. I’m glad you can work now!

4 Likes

Greetings, Gentlemen.

I Do indeed wonder how this new interesting instance works in code,

Is there any possible way to see the script of this object, I Might get some useful information from that.

2 Likes

In general, we prototype new built-in DragStyles by scripting lua examples. There are a few in the example worlds. One is the “Lift And Carry” (which as you see is a bit complex) and another very short one is “Throw-It” (which picks a new plane of motion when you click, so you move it parallel to the face of the cube. you’ve clicked on; it gives neat control). The lua examples show you ways that you can create new behaviors and we hope you do.

We can always fold these in to be automatically provided, but [a] we don’t want a super long list, and [b] we only want to do that with things we are certain are perfect for the behavior they promise. “Lift And Carry” is pretty complex, and not perfect, so we wouldn’t add it until, at the very least, we have enough feedback that it’s high enough quality. Plus, if you look at the script, there are a bunch of parameters like CARRY_DISTANCE and 4 parameters to limit the range of motion. We wouldn’t want to add the DragStyle without the controls, but we don’t want to add 4 new Properties just to support that DragStyle. Providing the best API is all a balance of utility and elegance, and it’s not an exact science.

2 Likes

@yousefaaaaa097 the DragDetector is a new instance available as part of the engine. It’s written in C++ and it’s not a lua script. We can’t share the code, but we’re not trying to keep any secrets here beyond that. Feel free to ask questions, and here is a summary of the architecture behind them:

  • First we watch for input clicks that hit the DragDetector’s parent part or model. That input can be mouse, touch, gameController virtual cursor, or VR laser pointer.
  • Then we map the motion of that input to virtual lines and planes to get a CFrame that specifies proposedMotion relative to where the object started. The lines and planes used vary depending on the chosen DragDetector.DragStyle. (TranslateLine, RotateAxis, etc.). And the result is a new translation and/or rotation. If the DragStyle is scripted, your own method (registered with SetDragStyleFunction) gets to pick that proposedMotion based on the cursorRay
  • Before finalizing the result, the proposedMotion is given to any constraint functions you’ve registered with AddConstraintFunction. Then the proposedMotion becomes the actual motion. It’s multiplied by the DragDetector.DragFrame (which measures the DragDetectors motion relative to the ReferenceInstance) and the DragFrame property is set with the new value.
  • Lastly, the DragDetector.ResponseStyle determines what happens next. If it’s Geometric, Anchored objects will have their pivot edited to move them; and non-anchored objects will be temporarily anchored for a similar change. If it’s Physical, Anchored objects behave the same but non-anchored objects are tugged around by hidden constraints. If it’s Custom, then nothing else happens. We don’t move the object. So you can make buttons this way (like the ones I showed about 10 posts up), or things that watch the DragFrame and trace out new objects (like the “create cubes” demos #22 and #23 in DragDetectors TestWorld 2).
  • All the above is done on the server, in response to dragStart/dragContinue/dragEnd events that are sent from the client to the server. These events have the same parameters as the ones in the callbacks you get to register. If the DragDetector.runLocally is true, the client doesn’t send events to the server, it just does the work itself.

(Edit: easy peasy. Just add 18 months work. :stuck_out_tongue: )

5 Likes