OverlayModule- Wrap decals around surfaces

I was looking for a solution to my post, and I came across a plugin that does exactly what I wanted. So, I turned it into a module for in-game usage!

Here’s what it looks like in action:

image

This is a bad example, but you might be starting to see what you can do with this! You could use it for bullet holes, blood, and more.

The code used to make this example:

Summary
local overlayer = require(game:GetService('ReplicatedStorage'):WaitForChild('OverlayModule'))

-- Since skinned meshes won't work in workspace soon
local overlayFolder = Instance.new('Folder')
overlayFolder.Name = 'Overlays'
overlayFolder.Parent = workspace

local decal = Instance.new('Decal')
decal.Texture = "rbxassetid://10422148194"
decal.Face = Enum.NormalId.Top

-- First param is self, which we use for :Update(), second is the actual mesh
-- .new's first param can be 'Low', 'Medium' or 'High'. Performance greatest to least.
local overlay, overlayInstance:BasePart = overlayer.new('High')
overlayInstance.CFrame = CFrame.new(-60, 11.5, -21, 0, -1, 0, 0, 0, 1, -1, 0, 0)
overlayInstance.Size = Vector3.new(4,0,4)
overlayInstance.Transparency = 1

-- Offset will be how much the overlay levitates from the surface
overlayInstance:SetAttribute('Offset', 0.001)
overlayInstance.Parent = overlayFolder

-- And finally, wrap it around the surface!
overlay:Update()

decal.Parent = overlay.overlay

Get the module here. Enjoy, and credit to Sol_ttu for the original plugin!

46 Likes

Question, how do you put this into a bullethole form?

Edit: Better way to put it, how do I wrap it around an object.

1 Like

I assume you’re making some sort of gun, so when the raycast fires, get the position that it landed at (RaycastResult.Position, I think), and then just position it slightly above where it landed, since this module literally projects the mesh. Hope that helps!

Can you help me with this? I used your example, and got this:

Code:

local decal = Instance.new("Decal")
				decal.Texture = "rbxassetid://"..wound_chosen
				decal.Face = Enum.NormalId.Front
				
				local overlay, overlayInstance:BasePart = overlayer.new('Low')
				overlayInstance.CFrame = CFrame.lookAt(pos, pos+bullet.Normal)
				overlayInstance.Size = Vector3.new(0.1,0.1,0)
				overlayInstance.Transparency = 0
				
				overlayInstance.Parent = folder
				overlayInstance.CanCollide = false
				
				overlay:Update()
				
				decal.Parent = overlay.overlay
1 Like

Does this work with multiple instances surfaces or just a single instances surface?
Lovely module btw, thank you for creating & sharing it!

the plugin was made using bones to manipulate the bones to match the surface… so its not really accurate

How can I use it with WorldToGui module? (with SurfaceGui)