How would I make an NPC that only follows if it’s within the drag detector radius?
I think for this you’d need to set up propertyChanged callbacks on both the NPC’s root location and the draggedPart’s (or model’s) pivot. Whatever distance you want to watch for could be read from any parameter you want. The DragDetector doesn’t really have a radius per se; but you could take the length of the (maxDragTranslation - minDragTranslation). The decision about whether to follow would be made by comparing (NPCPosition - draggedModelOrPartPosition) agains that radius.
Thank you for the answer, but also, do you know how I could limit the amount with a drag detector I can move something around my baseplate? For example how would I make it stop moving at half the radius of the baseplate?
If you set the dragDetector.ReferenceInstance to baseplate, and the minDragTranslation to (-halfWidth, -halfWidth, -halfWidth) and the maxDragTranslation to (halfWidth, halfWidth, halfWidth) then this will limit things to a BOX that is have the size of the baseplate.
If you want a circle, you need to add a constraint function using a script, but it’s not hard.
There is an example of a circular constraint function in DragDetector TestWorld 1, which you can download and edit via the “…” menu to the right of the title.
Look for demo #9A “Constrain within circle”
Note that we have had requests to make a distance-based constraint be built-in; we have it on the list of features to consider.
I think a part exclude system would be great to add, for example if a part was in the way of your mouse you could exclude, i know you could turn off can query but it would be a nice option to have
So I noticed that the drag detector does not work in the studio but does work on roblox so its imposable to test befor publishing if this could be fixed that would be Great.
Is there any plan on adding a pause drag option or force drag?
Im currently having issues with mobile users not being able to move their cameras whenever they’re inside a draggable building so i want the dragdetectors to only work whenever the user hold the part for a certain time period so they can still move their cameras.
Hi @timthetank13 you should be able to test your dragdetectors in studio.
If you make sure that all of the four Dragger tools (select, translate, scale, and rotate) are disabled, then the mouse events should fall through to your DragDetectors, and you should be able to test their motion.
If the part is anchored, then the motion should be the same in studio as in roblox. If the part is not anchored, then it will not move using physics in studio, although IK and constraints will be honored, so parts that are constrained to others will maintain those constraint releationships while dragging (same as ‘physical mode’ for the translate/rotate/scale draggers)
We left the lower left corner to give priority to camera controls over dragDetectors. So if the dragdetector covers the full screen, you should be able to use the lower left joystick to escape.
There’s not API to do what you want right now, but we do plan to add API that lets the developer say whether or not a player may drag a part. We’ve just gotten approval for this new API so it should come live in the not too distant future. The API will look like this:
DragDetector.PermissionPolicy = Nobody, Everybody, or Scriptable.
If Scriptable, then you may registera a callback like this:
DragDetector:SetPermissionPolicyCallback(function(player, optionalPart)
– return true if can operate, false or nil if cannot
end)
when a player clicks, the provided callback will be run to say whether a player may drag.
So you’ll have an opportunity to make whatever test you want, like “Is the player inside the building?” and perhaps return NO. I hope that will help you.
There is no way to check this in my game though.
In my scenario its a physics affected building which can move anywhere and can have thousands of blocks.
The only nonperformance heavy solution for this would be to hold a finger to drag instead.
Snap Feature? I can’t figure out how to make a grid lock system that carries collisions and doesn’t keep the same access and can go on-top of parts.
Hii i really love the addition of drag detectors but I have a question.
I’m making a jigsaw puzzle game, so how would I implement a click to rotate by 90 deg function? I know that drag detectors are derived from click detectors so how would that work?
Hi @rickje139, so you’ve separately requested that you be able to change the maxForce and maxTorque while dragging. This should go live next week. Is that feature going to give you a solution for this? You can have the maxForce be 0 at the beginning, and increase the force to greater than zero after a certain amount of time has passed?
Let me know if that will do it or if there’s something further you want to discuss on this topic.
There is no built-in snapping in DragDetectors, but…
You can also create a custom DragStyle that will place the object on top of others as you drag them. Check out the example “8: Frfeeform Dragging → Onto Other Objects” in DragDetectors TestWorld 1, which you can download and edit.
And you can add constraint functions that will snap to grids or let you modify the proposed motion in any way you like. Check out the examples in “27:Translation Constraints” in DragDetectors TestWorld 2, which you can also download and edit.
You can use either ClickDetectors or DragDetectors as buttons that will do whatever you want when the click is complete.
If you use a ClickDetector, then you just register a callback to the MouseClick event.
Or with a DragDetector, youi can register a callback to the DragEnd event.
Note that if you want a DragDetector to act as a simple button, you’ll want to set the ResponseStyle to Custom so that it does not move itself in response to mouse motion.
The two differences here are:
[1] with a clickDetector, you only get one event after you click down and up: MouseClick. But with DragDetector you get events on mouse down (DragStart) as well as mouse up (DragEnd) so you can change the looks of your button while it is held down
[2] If you move the mouse off of the geometry before releasing on a ClickDetector, then you will lose focus and MouseClick will not be triggered when you release. With DragDetector, you can move the mouse off after you press down, and when you release, you’ll still get DragEnd.
There are examples of 3 types of buttons you can create using DragDetectors in DragDetectors TestWorld 2 The examples change a particle system’s spray strength. There’s a regular style button that triggers a burst after you click and release; a second that sprays a burst while the mouse is held down; and a toggle button that sprays a burst while down, and toggles between two colors on every other click. You can download and edit this world to play with these variations.
is there any way of making it move along only 1 axis up to a certain distance from the player because currently with MaxDistance bit it would start to circle around which is very annoying
All issues i currently have will be solvable by changing the maxforce depending on the situations, however though i did notice some other issue.
Its not possible to exclude certain parts from the mouse raycasts which makes the dragged assembly’s move closer because of some invisible parts in my game.
I am not sure if this was actually caused by the invisible part or if it was some weird glitch.
Wow thank you for this information! I really appreciate you telling me about the drag detector test world, it’s been extremely helpful. I have one more question though: How would I be able to drag an object AS WELL as being able to rotate by 90 deg with a click. I’ve been testing with #5 in testworld2 and I’ve only been able to rotate it but without keeping the drag functionality. Thank you
I wonder if the DragDetectors in this game are scriptable, they don’t seem to have default behavior.
This is very cool, looks very simple to use and user friendly, I really like this direction ROBLOX is heading, instead of relying on players to program and script themselves, they instead are making features much more easier to use, hopefully one day ROBLOX adds blueprint scripting or some other kind of variation to which a person with no experience in scripting or no desire to script, can still program a game with countless features already designed for them capable of customization to fit the developers use and needs.