Hello,
I’m trying to make a spraycan that creates a decal once you click on the desired spot on your screen.
What I’m struggling with is verification to make sure the spot you’re placing the spraycan is a flat surface - otherwise it looks weird.
I thought of doing this via raycasting on each corner and seeing if the normal is the same.
At the moment I’m just trying to find the position of each corner and representing that with a part. Which is what is causing me trouble.
My current code (PartCFrame
is the centre of the spraycan part):
local Centre = Instance.new("Part", workspace)
Centre.Size = Vector3.new(0.5, 0.5, 0.5)
Centre.Anchored = true
Centre.CFrame = PartCFrame
local TopRight = Instance.new("Part", workspace)
TopRight.CFrame = PartCFrame + Vector3.new(5.25, 0, 4.5)
TopRight.Size = Vector3.new(0.5, 0.5, 0.5)
TopRight.Anchored = true
local TopLeft = Instance.new("Part", workspace)
TopLeft.CFrame = PartCFrame + Vector3.new(5.25, 0, -4.5)
TopLeft.Size = Vector3.new(0.5, 0.5, 0.5)
TopLeft.Anchored = true
local BottomRight = Instance.new("Part", workspace)
BottomRight.CFrame = PartCFrame - Vector3.new(5.25, 0, 4.5)
BottomRight.Size = Vector3.new(0.5, 0.5, 0.5)
BottomRight.Anchored = true
local BottomLeft = Instance.new("Part", workspace)
BottomLeft.CFrame = PartCFrame - Vector3.new(5.25, 0, -4.5)
BottomLeft.Size = Vector3.new(0.5, 0.5, 0.5)
BottomLeft.Anchored = true
The spraycan part is 9, 10.5, 0.2
studs
My code results in this on a flat horizontal surface (works):
https://gyazo.com/bb946ba4cc266d06d113c577a4df1704
And this on a flat non horizontal surface (doesn’t work):
https://gyazo.com/83eca2cf35d5289d2b8dbe7ff521f59e
https://gyazo.com/2c00756c54dfa888a48937e06ccd0490
Any ideas/suggestions you have would be greatly appreciated,
Tweakified