I'm making a little system where I can spray things with water. I've got all the particles, raycasts and all those things working except spraying something doesn't actually do anything. What I want to do is make the object look "wet" or "damp" after I have sprayed it. I want to be able to stamp transparent circles on 3d objects to make this effect. I'll stamp them at the mouse cursor's position.
I'm either going to use surface guis on the sides or thin parts with decals on them.
Both techniques have downsides.
Thin parts is a ton easier but when I spray at the edge, the side of the thin part hangs over.
Surface guis can obviously clip stuff like this out, but I'm struggling to find a way to convert my mouse's position into a position on a surface gui ):
So has anyone got any ideas. Does anyone know a way to convert my mouse's position into a position on a surface gui?
Btw, here's the script I'm trying for the surface gui thing.
if mouse.Target then
if mouse.Target:IsA("BasePart") or mouse.Target:IsA("WedgePart") then
local surface = mouse.TargetSurface
local surfacegui
if mouse.Target:FindFirstChild(surface.Name) then
surfacegui = mouse.Target:FindFirstChild(surface.Name)
else
surfacegui = Instance.new("SurfaceGui")
surfacegui.Name = surface.Name
surfacegui.ClipsDescendants = true
surfacegui.Face = surface
surfacegui.Parent = mouse.Target
end
-- Get Position
local GuiParentPart = mouse.Target
local TopLeftCFrame = GuiParentPart.CFrame * CFrame.new(GuiParentPart.Size.X / 2, GuiParentPart.Size.Y / 2, GuiParentPart.Size.Z / 2)
local MouseDistanceFromTopLeft = TopLeftCFrame.Position - mouse.Hit.Position
local pos = UDim2.new(0, MouseDistanceFromTopLeft.Z * surfacegui.PixelsPerStud / 2, 0, MouseDistanceFromTopLeft.Y * surfacegui.PixelsPerStud / 2)
img = Instance.new("ImageLabel")
img.AnchorPoint = Vector2.new(0.5,0.5)
img.Size = UDim2.new(0,300,0,300)
img.Position = pos
img.Name = "WaterSplat"
img.BackgroundTransparency = 1
img.ImageTransparency = 0.7
img.Image = "http://www.roblox.com/asset/?id=200182847"
img.Parent = surfacegui
end
end
DEMO:
https://i.gyazo.com/bbcc1e6ebb19bc7d81bdf85455225c3f.mp4
The amazing thing is it partially works. If I spray on a specific side of the part, it works. (For me it's the right side) Other sides are bugged up though
Maybe what I have so far will work if I find a way to fix up the bugged sides, but I'm 99% there's a better way!
Well, I really want a solution and this isn't any easy thing to find an answer. But if anyone does and can tell me, may your life be filled with happiness ????
Any questions, then please ask
