Hello all! I am working on a system using IntersectOperation. This is how i can best describe my problem:
Using intersectAsync function via code does not produce same result as using the intersect button in studio.
Here is the code that i am using to put decals on my intersectOperation:
local function GetIntersection(hit,ray)
local newhit = hit:Clone()
newhit.Transparency = 0
newhit.Color = Color3.new(1,0,0)
local Intersection = newhit:IntersectAsync({ray})
return Intersection
end
module.PrintRay = function(ray) -- raycast
local hit = Instance.new("Part")
hit.Name = "Sec"
hit.Anchored = true
hit.CanCollide = false
hit.CanQuery = false
local height = 0.25
local width = 0.25
hit.Size = Vector3.new(width,height,0.25)
hit.CFrame = CFrame.lookAt(ray.Position, ray.Position + ray.Normal) -- * CFrame.new(0,0 (hit.Size.Z * 2))
local cf = hit.Orientation
hit.Transparency = 0
hit.Parent = workspace
local Part = ray.Instance
local newhit = GetIntersection(hit, Part)
newhit.Parent = workspace
-- Sometimes its on the backside, idk why
local bulletdecal = Instance.new("Texture")
bulletdecal.Parent = newhit
bulletdecal.Texture = "rbxassetid://" .. BulletDecalID
bulletdecal.OffsetStudsU = width/2
bulletdecal.OffsetStudsV = height/2
bulletdecal.StudsPerTileU = width
bulletdecal.StudsPerTileV = height
bulletdecal.Face = "Front"
local bulletdecal2 = Instance.new("Texture")
bulletdecal2.Parent = newhit
bulletdecal2.Texture = "rbxassetid://" .. BulletDecalID
bulletdecal2.OffsetStudsU = width/2
bulletdecal2.OffsetStudsV = height/2
bulletdecal2.StudsPerTileU = width
bulletdecal2.StudsPerTileV = height
bulletdecal2.Face = "Back"
newhit.CanCollide = false
newhit.CanQuery = false
end
This is what happens when it is executed:
NOTE:
The mouse in the video is duplicating the wedge and then selecting the square, and intersecting it with the wedge. The order of selecting parts matter
The red ones are the one done via code. The ray.Instance is a wedge, but it has similar problems with blocks and really all types of things. Sometimes the decal is printed on the opposite face, so i added 2 different decals.
Observations:
It helps if you via code face the square the same direction as the part you are intersecting with, didnt work if the part was on an angle other than 90.
Flipping the IntersectAsync makes things worse.
Is this a roblox bug? The video and excessive testing has resulted that if you do the intersections via roblox (not by code) it works perfectly. If you need more context it will be given. The code block is a simplified version of the actual code