I am having troubles making a drag system similar to work a pizza place or roblox studios
even using the drag detectors and shape casts
i cannot get half the result i want
--in the script
local object = script.Parent
local dragDetector = object.DragDetector
local raycast = require(script.Raycast) --object follows where mouse is
local constraint = require(script.Constraint) --limit object position to a radius
local radius = 25
dragDetector:SetDragStyleFunction(function(cursorRay)
return raycast(cursorRay, dragDetector, object) --this sets the object position
end)
dragDetector:AddConstraintFunction(1, function(proposedMotion)
return constraint(proposedMotion, dragDetector, radius)
end)
--inside of raycast module
return function(cursorRay, dragDetector, object)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {object} -- Ignore the player’s character
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
local raycastResult = workspace:Raycast(cursorRay.Origin, cursorRay.Direction, raycastParams)
local hitPosition = raycastResult.Position
return CFrame.new(hitPosition)
end
--i do not know how to do the constraint to limit by the radius
I would like to make a custom response style for the drag detector of a mix of the smoothness of physics and the rigidness of geometric
raycasts work by hitting an object and sending the position where it hits
but when setting the pizza to that position it is half way in the wall
there’s a hacky solution that uses the normals to displace the pizza
local offset
if math.abs(hitNormal.Y) < 0.5 then
-- Wall detected → Offset away from the wall based on its normal
offset = hitNormal * pizzaRadius
else
-- Floor or ceiling detected → Offset along the normal
offset = hitNormal * pizzaHeight
end
return CFrame.new(hitPosition+offset) * CFrame.Angles(0,0,math.rad(90))
however it does not work against walls that are rotated
so i thought about using shapecasts, however they have their own set of problems
the square is rotated based on the origin of the raycast, and i need it not be rotated on the world position.
not only that but the shapecast you can somehow get them to go through the floor and that is not a unreliability that i want