How would I stop these two parts from colliding?
Mouse.Move:Connect(function()
if isMouseDown == true and Target ~= nil then
Target.Position = Mouse.Hit.Position + Vector3.new(0,0.7,0)
end
end)
How would I stop these two parts from colliding?
Mouse.Move:Connect(function()
if isMouseDown == true and Target ~= nil then
Target.Position = Mouse.Hit.Position + Vector3.new(0,0.7,0)
end
end)
You can create a collision group to prevent the 2 parts from colliding
It does not exactly work to well. I still receive the same outcome.
You have to set up a Mouse target filter so the mouse doesn’t obtain the hit position of the object you are trying to not be collide with. The part would then move onto the ground behind the wall instead of against the wall, as shown in the video you posted.
What would i set the mouse target filter to?
a table of objects that you want the mouse to ignore.
for example: local filter = { workspace.Part1, workspace.Part2, }
tho you can’t save instances to tables
yea thats what I was thinking also.
Oh I am sorry, I got confused with another filtering thing.
You could just use a “Model” as a folder of parts, then put parts in there that you want filtered since it does get all child objects.
I made a custom dragger that uses raycasting with raycastParams instead of Mouse Filter, although this might be a bit expensive.
local flatSurface = Instance.new'Part'
flatSurface.Anchored = true
flatSurface.CanCollide = false
flatSurface.Transparency = 1
flatSurface.Size = Vector3.new(100,2,100)
flatSurface.Parent = workspace
local cam = workspace.Camera
local mouse = game.Players.LocalPlayer:GetMouse()
local rayDragParamas = RaycastParams.new()
rayDragParamas.FilterType = Enum.RaycastFilterType.Whitelist
rayDragParamas.FilterDescendantsInstances = {flatSurface}
local target, dragging = nil, false
local yFlat = Vector3.new(1,0,1)
local targetOffset = Vector3.zero
mouse.TargetFilter = flatSurface
mouse.Move:Connect(function()
if dragging and target then
local ray = workspace:Raycast(cam.CFrame.Position,mouse.Origin.LookVector*128,rayDragParamas)
if ray then
target.Position = ray.Position*yFlat+targetOffset
flatSurface.Position = ray.Position-Vector3.yAxis
end
end
end)
mouse.Button1Down:Connect(function()
target = mouse.Target
if target then
dragging = true
flatSurface.Position = mouse.Hit.Position-Vector3.yAxis
targetOffset = (target.Position - mouse.Hit.Position)*yFlat + target.Position*Vector3.yAxis
end
end)
mouse.Button1Up:Connect(function()
target, dragging = nil, false
end)
edit: im making lots of edits in the code to make it run better, and look exactly like the studio dragger