you would need to either use a roblox api (like GetTouchingParts) or code your own bounding system (which is pretty complicated but I can explain deeper if you need)
I’m a little confused on the GetTouchingParts because I’ve looked up this issue and can’t find a solution, but a lot of the responses said something about GetTouchingParts. How could I use this for collisions?
Also, I’m pretty sure GetTouchingParts is performance heavy. Would it be better to use GetTouchingParts or a bounding system?
You can use the GetPartsInPart method in workspace to detect your part colliding with others, which to my knowledge is more stable and optimized than GetTouchingParts. If GetPartsInPart returns a table with at least one part, then make it so the player can’t place their part.
That’s not what I was looking for, though. I don’t want to prevent the player from placing the part, I want the part to be aligned properly, like it’s shown in the video from my original post
In that case, you’d have to offset the part by half of the part’s size on a certain axis using the raycast’s normal, something like this:
local function GetOffsetDirection(normal)
for _, normalId in pairs(Enum.NormalId:GetEnumItems()) do
local normalIdDirection = Vector3.FromNormalId(normalId)
if normal.Unit:Dot(normalIdDirection) > .999 then
return normalIdDirection
end
end
end
local offsetDirection = GetOffsetDirection(raycastResult.Normal)
local offset = (Part.Size * offsetDirection) / 2
Part.Position = raycastResult.Position + offset
This only works for parts that are rotated on a 90 degree grid, anything inbetween it won’t work because I have no idea how to go about doing that.
Yea, that’s my main issue. I appreciate the script though, it’s a temporary fix. I’ve been trying to define every corner’s position on the part and loop through them, and try to somehow figure out how to offset the corner of the part to be aligned properly
Most draggers like this use the dragger instance which is deprecated, and leaves us with not many options