I tried to simplify the title as much as possible because it’s a bit complicated. I’m making a circle get chunks of it cut off it it is over an edge. The circle has a bunch of attachments as origins and directions for raycasts. Each attachment was coded to have a cframe that is pointed towards the origin of the part(but this is the problem).
Since the attachments are facing the part, the negative part subtracts chunks around it like a circle, but this isn’t how it should be. When it chops off a chunk the negative part should be is the same direction as the edge. How do I get the direction of the edge?
Yes. Every task.wait() it raycasts from every attachment with a length of 1(for now), and if the raycast is nil then it creates a part, and uses subtract async on the part.
Sounds like you could just run :inverse on the Cframe to flip its direction, then it would point away from the center and not towards it. I think that answers your question…
Yes. And the code is going to be for a blood pool that doesn’t float over edges.
if you have a better way pls tell me this is laggy
local part = workspace.Pool
task.wait(1)
while task.wait() do
for i,v in pairs(part:GetChildren()) do
if v:IsA("Attachment") then
local rpm = RaycastParams.new()
rpm.FilterType = Enum.RaycastFilterType.Blacklist
rpm.FilterDescendantsInstances = {part}
local rayc = workspace:Raycast(v.WorldPosition,v.WorldCFrame.UpVector*-1,rpm)
if not rayc then
task.wait()
local part1 = Instance.new("Part")
part1.Size = Vector3.new(100,100,100)
part1.Orientation = v.WorldOrientation
part1.Position = v.WorldPosition + v.WorldCFrame.LookVector*-50
v:Destroy()
local newpart = part:SubtractAsync({part1},Enum.CollisionFidelity.PreciseConvexDecomposition,Enum.RenderFidelity.Performance)
part1:Destroy()
newpart.Name = "Pool"
newpart.Parent = workspace
for j,x in pairs(part:GetChildren()) do
if x:IsA("Attachment") then
local cf = x.WorldCFrame
x.Parent = newpart
x.WorldCFrame = cf
end
end
part:Destroy()
part = newpart
end
end
end
end
I can look into some other solutions, but how about a SurfaceGui on the part you’re landing on, and a ImageLabel with a blood texture on that Gui?
That would work for lots of cases, might be great depending on your level geometry. Wouldn’t be perfect but would probably look better than this approach generally.
Couldn’t you do some math using the part’s size and position along with the bloods size and position to determine where the edges of the part are and if the part goes over them and by what percent? It would be less dynamic because it only considers the bounding box, not the actual part, but would be cheaper on the server