Seems like it’s missing a few bits like remote events, if this is server side whats the client side.
The documentation is okay but does not show how to make bricks moveable like the logs in Lumber Tycoon 2. That would be good to know please.
I’ve had a go in the test worlds opening them in studio but no functions are working :S is that something wrong my end or the world?
The callbacks like connections to dragStart/continue/end, or the constraint functins are custom drag styles, don’t run in studio; the scripts that run them are run in games, but not in studio. is that your issue? Or do they not even run when you are in play mode?
If you’ve never tried DragDetectors in studio you need to turn on the beta, but I doubt that’s your issue.
If this isn’t it, please describe your issue more clearly
The code from @MintSoapBar was a snippet, not the whole thing.
Also, that code ONLY works if you are in first person otherwise the object stays in front of the camera, not in front of the avatar.
Picking up and carrying, lumber tycoon style, seems to be something a lot of you want, and it’s not obvious how to do it.
I’m going to try to work up an example that does it nicely, and post it here.
I won’t get to this today but I’ve set aside time for it tomorrow; i hope to post something by end of day.
If minTranslation is greater than maxTranslation (which may be the case if you set min to the player’s distance to the part), it won’t limit the translation on that axis by design. Max needs to be greater than min. That could be why it’s not following you.
As for the flying away-- I’ll need to test this!
Hi @foodeggs7,
I’m not going to be able to help you with the fan unless you send or post a game with the model in it. It’s too hard to help you from your description.
As for DragDetectors in Tools:
If you put a DragDetector under a part in a Tool, it does not receive events. So DragDetectors can’t work at all in tools. I’ll add a task to our system to look into it, but this will not be a high priority, at least not now.
Hey there, just requesting that there be a property in the drag detector that can toggle whether the origin of the ray is at the camera’s position or the camera focus’s position, or a custom position.
Note: If we get the ability to change the origin to be the player’s character instead of the camera, we can just combine that with the custom drag style code I posted and we’ll have that lumber tycoon drag style a lot of people seem to want, and it’ll be a lot more intuitive for newer developers to grasp than messing with max/min translations
Well, that’s not really how it works.
When you click and drag, your ray has an origin and direction based on how you are ‘drawing’ on the screen. You’ve got to use that ray to find your intersections, and then work from there. If we just change the origin and not the direction, the ray will hit something completely different,
You are using a ray in a different way for placement. You’ve still got to use the real ray to find what you’ve clicked on, but from there, you don’t care about the subsequent rays because you want to do a different operation. You want nicely conditioned rays emanating from the user to place them relative,and that’s a different function. I don’t believe there’s any further buildt-in support required from dragdetectors to do DragStyles that operate relative to the viewer; it can be done in lua.
Like I said, I’m going to try to work up an example that’s nicely organized so others can use it, since it’s a common request.
There are actually several custom drag styles that are cool but not prepackaged; as well as cool action that you can get by changing the dragStyle or axis or referenceFrame during dragStart. That’s why we’re providing the two sample worlds and the sample models in the toolbox.
We opted to keep the set of prepackaged dragstyles low; we can always bundle more in later, but for now we want to see whether lua is too much of a burden and whether the creator community can thrive as is. Also, I think this sort of thing may have a lot of variations and customization, so it may be better to give it to you in lua so you can change it to your needs.
Stay tuned.
Okay, folks, I’ve made an attempt to create a Lumber Tycoon style “Lift And Carry” demo for you to work with.
I’ve done two that are similar: one is moved physically with constraints, the other geometrically (temporarily anchored and moved by editing the pivot).
They perform collisions with blockcast so that even the geometric one gets placed atop objects.
They work in both first person and third person modes. In third person I tried to do something a little like Lumber Tycoon, where you can drag the object in a plane in front of the character.
You can get them in two ways:
[1] Go to this game. It should be set up for you to download. Lift And Carry - Roblox
[2] You can grab the models individually from the toolbox:
Lift And Carry: Physical - Roblox
and
Lift And Carry: Geometric - Roblox
Thanks to @Deadwoodx, @Wertyhappy27, @kirbyFirer, @MonsterStepDad, and @MintSoapBar and all the others whose suggestions helped me get this far.
If you have improvements, it would be great if you shared with this group so I can update these and all can benefit; I’ll include you in the credits I’ve put in the scripts.
Below are gifs of the physical version in third and first person.
@PrinceTybalt
This is fantastic, i’m just working on the part where the server add’s the bits it needs to run so only the localscript is showing on the parts and the rest are called.
Is it possible to have it rotate by user input? such as twist on the xyz axis pending on what ever way the user wants?
So far i’ve added this to my axe script when creating a log. so now it works when making a log.
-- Create a new log part based on the tree type
local logPart = Instance.new("Part")
logPart.Name = treeType .. "Log" -- Example: CandyTreeLog
logPart.Size = Vector3.new(2, 20, 2) -- Adjust size as needed
logPart.Position = target.Position
logPart.Anchored = false
-- Fetch the LocalScript from ReplicatedStorage
local replicatedStorage = game:GetService("ReplicatedStorage")
local existingLocalScript = replicatedStorage:FindFirstChild("LiftAndCarry_Physical_ClientScript")
-- Check if the LocalScript exists
if existingLocalScript then
-- Clone the existing LocalScript
local clonedLocalScript = existingLocalScript:Clone()
-- Parent the cloned LocalScript to the new log part
clonedLocalScript.Parent = logPart
end
-- Clone the DragDetector from ReplicatedStorage
local existingDragDetector = replicatedStorage:FindFirstChild("DragDetector") -- Replace with the actual name
-- Check if the DragDetector exists
if existingDragDetector then
-- Clone the existing DragDetector
local clonedDragDetector = existingDragDetector:Clone()
-- Parent the cloned DragDetector to the new log part
clonedDragDetector.Parent = logPart
end
logPart.Parent = workspace
-- Add "Health" attribute with the determined value
local logHealth = Instance.new("IntValue")
logHealth.Name = "Health"
logHealth.Value = healthValue
logHealth.Parent = logPart
-- Add "Worth" attribute
local worthValue = Instance.new("NumberValue")
worthValue.Name = "Worth"
worthValue.Value = originalWorth -- Set the value from the original tree trunk
worthValue.Parent = logPart
local configValue = Instance.new("StringValue")
configValue.Name = "Configuration"
configValue.Value = "Draggable"
configValue.Parent = logPart
CollectionService:AddTag(logPart, "Draggable")
--add owner tag
local ownerValue = Instance.new("IntValue")
ownerValue.Name = "Owner"
ownerValue.Value = player
ownerValue.Parent = logPart
-- Add "Creator" attribute to mark ownership
local creatorValue = Instance.new("ObjectValue")
creatorValue.Name = "Creator"
creatorValue.Value = player -- Set the value to the chopping player
creatorValue.Parent = logPart
-- Apply properties from the trunk to the log
logPart.Material = treeInfo.trunkMaterial
logPart.BrickColor = treeInfo.trunkColor
-- Handle any other necessary actions for the log part, such as physics, appearance, etc.
-- Start the function to destroy the log after 30 minutes
spawn(function()
destroyLog(logPart)
end)
-- Call the regrowTree function after a delay (e.g., 1800 seconds or 30 minutes)
spawn(function()
wait(10) -- Adjust this delay as needed
regrowTree(treeType, target.Position, target)
end)
end
end
I’ve placed the following in ReplicatedStorage:
DragDetector
LiftAndCarry_Physical_ClientScript
RequestNetworkOwnerShipEvent
In ServerScriptService i’ve added this:
LiftAndCarry_Physical_ServerScript
Now here are some amendments to the actual scripts.
Localscript
wait(0.5) --added this otherwise the script errors out before running
local dragDetector = script.Parent.DragDetector
local CARRY_DISTANCE = 8
local lastViewFrame = CFrame.new()
local myMovingPart = script.Parent
local replicatedStorage = game:GetService("ReplicatedStorage")
local requestNetworkOwnershipEvent = replicatedStorage:WaitForChild("RequestNetworkOwnershipEvent")
local function fireRequestNetworkOwnershipEvent(clickedPart)
requestNetworkOwnershipEvent:FireServer(clickedPart)
end
Serverscript:
local replicatedStorage = game:GetService("ReplicatedStorage")
local requestNetworkOwnershipEvent = replicatedStorage:WaitForChild("RequestNetworkOwnershipEvent")
local function onRequestNetworkOwnership(player, part)
part:SetNetworkOwner(player)
end
requestNetworkOwnershipEvent.OnServerEvent:Connect(onRequestNetworkOwnership)
Now it works well with the log’s. However I think it should grab to the point i’ve grabbed it. How can we achieve this?
I’m working yesterday and still the screw go out the wall now I tried with welds and the script but you cant drag the screws and the fan clitch out the screws I have a video and an place file attached here
Thanks for giving this a look and especially for reporting back with your suggestions.
[1] “Is it possible to have it rotate by user input? such as twist on the xyz axis pending on what ever way the user wants?”
Yes. You just need to watch for events separately (or check for key states during dragContinue callbacks) and apply arotation. I felt that was maybe a separate exercise so I didn’t add it. But since you all probably regard this as “part of the feature” I may add it
[2] Your log script seems pretty custom to your use case, but it would be neat to add a button to the world that creates draggable logs. May I add it to the game with your name if I credit you in the script?
[3] Regarding the location of the scripts and events: I used to put them in the places where you’ve moved them. But @YasuYoshida send me an example that bundled them below the DragDetector and I thought it was nice because you can copy and paste just the model as a prepackaged unit. I think I may update the game to show it done both ways; and steal @YasuYoshida 's little labeled platforms to make it clear which is which.
[4] That’s weird with the wait(0.5)., Is this common practice? What kind of error do you get?
[5] If you want to lift by the point where you grab it, just set DragDetector.ApplyAtCenterOfMass to false. The default is actually false, but I felt that the motion was more like Lumber Tycoon with it set to true.
I will look as soon as I can.
We are working on a Very Important Announcement today so I may not get to it today.
Hi folks,
I have greatly improved the 3rd person action on the Lumber Tycoon style dragging example to be more like the original and less jumpy.
The plane of motion is now always vertical and facing the camera, but located beyond the character.
If you are looking up or down we switch to a sky/ground plane.
I also upped the MIN_X_PLANE_OFFSET and MAX_X_PLANE_OFFSET and MAX_Y_LANE_OFFSET to -10, 10, and 10
Also, in physical mode, if there’s a collision, we try to place it a little farther then the collision so that forces act to push it along the surface and over. corners. We don’t do this for Geometric because then they would just interpenetrate
@monsterStepDad and others, please grab the game or models again for the change.
Lift And Carry - Game
Lift And Carry - Physical
Lift And Carry Geometric
@PrinceTybalt thank you.
- that would be awesome as it’s a standard feature really.
- you don’t need to credit me but go ahead and add it.
- they all seems to work fine in the locations i’ve put.
- yes it says DragDetector not located but thats because i’m cloning the drag detector from replicatedstorage to each log created. so I needed the wait(0.5) otherwise the script runs and it’s not been cloned over yet.
- thanks for this i’ll try that out.
I did notice that it does not actually place on items very well it seems like it’s actually got a barrier to a certian height and then drops down, rather than just dropping on it.
please see vid.
robloxapp-20231010-1130125.wmv (1.6 MB)
Hey there, there’s this one part of the comments in the model for physical dragging that doesn’t seem right
EDITED:
Did you just mean that I list both models in the script for each of the two examples?
I made it so that each one only mentions the one correct model.
Of if that’s not the issue, maybe see below:
=====
I recorded this video. Is this not working for you?
If not, what’s going wrong?
Or are my instructions different than what I’m doing in the video?
Regarding rotation:
Standard feature? I thought only one game has this in the first place. ?
But we are gonna make it standard!
So: How important is it to use Shift.+ WASD, as opposed to 4 other keys? I can get walking to pause if you do WASD to walk and then hit shift. But I can’t get it to start back if you release the shift. I suspect lumber tycoon has its own controller.
And as for your last problem: It could be one of two things:
[a] I built in a maximum y to the scripts, and you can change it. Look for MAX_Y_PLANE_OFFSET and set it higher., I just upped it to 15 and republished the game and models.
[b] or it could be that the object gets ‘caught’ on corners. I’ve fixed this in the physical case by attempting to place it a little farther away; this give it a little push to slide over corners and along surfaces. But I can’t do this for geometric movement because then it would just sink into the surface. I also think the blockcast that I am using to find the placement is a little wonky TBH.
Is there a way to add a drag detector to the player so you can drag them around? char
I haven’t tried it but you’d have to do something pretty crafty. It’s not really their intended use and player motion is controlled by all kinds of scripts. Maybe you could disable the scripts or put the player in a custom mode and then put a dragdetector under the humanoid root?
On the other hand, if you stand on an object with a dragDetector you can pull that object and go for a ride.
Let’s go surfing!!!
Might even be better with a proper seat object…