Hello. I need help figuring out how to use UIDragDetectors better.
It’s Scriptable, I was testing stuff out, and it seems like it works fine other than the fact that I can’t like drag it up in the air, it’s like its stuck on the floor, for some reason.
this is what ive got:
local Workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")
local dragDetector = script.Parent.Parent.DragDetector
dragDetector.Enabled = true
dragDetector.DragStyle = Enum.UIDragDetectorDragStyle.Scriptable
local carrying = false
local carriedObj = dragDetector.Parent
local player = game.Players.LocalPlayer
local camera = Workspace.CurrentCamera
local offsetCFrame = CFrame.new()
dragDetector.DragStart:Connect(function(inputPosition)
carrying = true
local objCFrame = carriedObj.CFrame
offsetCFrame = camera.CFrame:ToObjectSpace(objCFrame)
end)
dragDetector.DragEnd:Connect(function(inputPosition)
carrying = false
end)
dragDetector.DragContinue:Connect(function(inputPosition)
end)
RunService.RenderStepped:Connect(function()
if carrying and carriedObj and carriedObj.Parent then
local camCF = camera.CFrame
local forward = camCF.LookVector
local targetPos = camCF.Position + forward * 4
local targetCF = CFrame.new(targetPos) * offsetCFrame
carriedObj.CFrame = carriedObj.CFrame:Lerp(targetCF, 0.3)
end
end)
I appreciate any kind of support. thanks and bye.