Hello. I am making a game in which I need to know when there’s an overlapping between parts. I know how to use getPartsInPart and other of those functions. However, it returns the entire parts that touches. I want the specific areas where they are overlapping, and not the entire part. For example, if only the tip of one part is touching another, I want to get that small tip area only. The reason is because I want it so that when two parts touch, their overlapping places become a kill part but the other parts that aren’t touching is still normal. How can I do this? Thank you very much if you read until the end!
May you provide an example on how I would obtain that result region3?
Not related to your reply, but, you want to get a overlapping Area’s Size and position, right?
(plz reply so that i can help you deeper)
Correct, i just want to know the area that is overlapping so I can create a third part which is the overlapping area
Actually, it is easy
local function getCFrameAndSizeonIntersect(part1, part2)
local int = part1:IntersectAsync(part2)
local cframe = int.CFrame
local size = int.Size
return cframe, size
end
This will return a CFrame, and Size of Intersected result of part1 and part2.
Wow it’s that easy? I will look into intersectAsync right now
Hello, it turns out that IntersectAsync() can only be called from the server. How can I use it from the client?
As I have stated, I need to know the area in which those parts overlap.
Do you need the size of the intersection, position, or both?
I need both the size and position of the intersection
local function GetOverlapArea(part1:BasePart, part2:BasePart): (Vector3, Vector3)
local part1Position = part1.Position
local part1Size = part1.Size
local part2Position = part2.Position
local part2Size = part2.Size
local overlapMin = Vector3.new(
math.max(part1Position.X - part1Size.X/2, part2Position.X - part2Size.X/2),
math.max(part1Position.Y - part1Size.Y/2, part2Position.Y - part2Size.Y/2),
math.max(part1Position.Z - part1Size.Z/2, part2Position.Z - part2Size.Z/2)
)
local overlapMax = Vector3.new(
math.min(part1Position.X + part1Size.X/2, part2Position.X + part2Size.X/2),
math.min(part1Position.Y + part1Size.Y/2, part2Position.Y + part2Size.Y/2),
math.min(part1Position.Z + part1Size.Z/2, part2Position.Z + part2Size.Z/2)
)
local overlapSize = overlapMax - overlapMin
local overlapPosition = overlapMin + (overlapSize / 2)
return overlapSize, overlapPosition
end
Here is a function that will return the size and position of the overlap.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.