Announcing DragDetectors!

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

@x_maks441 another user, @Sho_Takahashi, was having the same problem.
They solved it by disabling some of the plugins they had installed in their Roblox Studio.
Try disabling yours and see if it solved the problem?

3 Likes

Is there a way to cancel a drag in DragStart/DragContinue (e.g. if the character dies)? I could disable the drag detector I suppose, but want to know if there’s a nicer way to do it that doesn’t require tracking all dragdetectors in the world (i.e. simply disallow it at the time it’s invoked).

Also a note about the example, here if you don’t add a case to use the rootpart instead of the head if it’s missing (custom characters), it will fall back to using the cursorRay which means players can drag objects wherever they can zoom out their camera to. This is also a place where I would want to cancel the drag instead.


(Technically you don’t even need to use the Head part either, but some games do different things to the body parts in first person, so this is fine)

5 Likes

I believe the easiest way at the moment is to disable the dragDetector. That will terminate any existing drags on that dragDetector.

You could immediately re-enable it on the next line, and it should be ok.

An API to cancel drag on request is something that’s been brought up many times though-- we will discuss if the current solutions provide enough, or if we need something more.

Please let us know if this works, and if you find cases where this would not be a desirable approach, let us know!

Some other niche behavior: moving the dragDetector’s ancestry (its parent, or itself to another parent) will also terminate any existing drags.

4 Likes

If the character performing a drag respawns, the DragDetector should close out any drag that is in progress automatically. If you do not see this behavior, please give us details.
This doesn’t happen when they die without respawning, because we want games to allow ‘ghosts’ to drag things around if that’s their desire.

If you want to disable at a particular time for a different reason, though, as @DeFactoCepti said, your easiest way is to set DragDetector.Enabled to false (and back to true if you like to clean up). And so I guess you have to write some kind of script to track which DragDetectors you care about. You can add some info to a list in a module during the dragStart() callback that registers the player and the dragDetector; and when players die you can check that list and disable the associated in-progress dragdetectors; then remove them from that list during a dragEnd() callback.

Thanks for the tip about the rootPart for the Lift-and-carry demo. I’ll update it on Monday!

3 Likes

i understand that having a lengthy list will be confusing, but i think the current system that the physical and geometric drag parts use in “Lift And Carry” would probably be the ideal outcome when you think of a DragDetector. Obviously, it wouldn’t function as intended but it seems to be the most stable and probably preferred output, instead if having a cube being flung thousands of metres at mach 10 if you look too far right.

3 Likes

@xynxae try using the DragStyle “TranslateViewPlane” which translates the object parallel to the view plane. It doesn’t give you the exact distance control of the lift and carry demo, and in 3rd person it doens’t place the object in front of the character. But it does keep the object moving in a frontal plane whichever way you face.

3 Likes

I have set my dragdettectors world public come test my creations

2 Likes

Did you restart studio after turning off plugins? I already turned off half of my plugins and yet did not help

3 Likes

This is great! Congratulations @foodeggs7 ! I love the tower. :slight_smile:

3 Likes

Is there anything printed in the output window? That helped us @Sho_Takahashi figure out when he had disabled the correct plugin because the unexpected output disappeared. I would turn them ALL off. You can always turn them back on.

2 Likes

I never got anything in output. That’s weird.
Right now going to test without any plugins on

3 Likes