Making a decal bend around corners

Hello fellow developers! I am making a spray bottle, and it’s working, the only problem I have that when you spray around corners, it looks weird, here’s a screenshot:


I want to wrap it, but I don’t know how to achieve that. Any help would be appreciated, here’s the code:

local player = game:GetService("Players").LocalPlayer

local Mouse = player:GetMouse()

local wallDetector = script.Parent:WaitForChild("WallDetector")

local sprayPaint = script.Parent

sprayPaint.Activated:Connect(function()

	local ray = Ray.new(Mouse.UnitRay.Origin, Mouse.UnitRay.Direction * 40)

	local hit, pos, normal = workspace:FindPartOnRayWithIgnoreList(ray, {sprayPaint, player.Character})

	if hit then
		local primary = game:GetService("ReplicatedStorage").Prim:Clone()

		primary.CFrame = CFrame.new(pos, pos + normal)

		primary.Parent = workspace
	end

end)
1 Like

I dont know if you can split a decal on two parts by percentage… gl with the project tho

there is a hard way and not performance-friendly.
you can do two ray casts. first ray cast at mouse position + Vector3.new(1,0,0) and mouse lookvector * 100,
second ray at mouse position + Vector3.new(-1,0,0) and mouse lookvector * 100,
then you get hit, position, normal, material
local hit, position, normal, material = workspace:FindPartOnRay(ray1)
local hit2, position2, normal2, material2 = workspace:FindPartOnRay(ray2)
check if the normal is not = normal2(hit2)
then create a new image and if you have any problem message me

hope this helped