DistanceFade - A transparency falloff effect for your games

This is such an amazing module, I’ll definetly be using this for one of my upcoming projects. How long did it take you to create this?

2 Likes

Thx a lot, i was working on it on the side and it took about 3 weeks. The original effect was done with ViewportFrames but they were way too laggy so I basically had to start from scratch a week in

5 Likes

of course!

words words words words words

3 Likes

Looks pretty good man, i’ve been looking for something like this :+1:

2 Likes

Really cool effect - is there a way to go about getting all children in the folder without manually listing each one and naming them? attempting to just use GetChildren() throws the error “DistanceFade:173: attempt to index nil with ‘Z’”

1 Like

I’ve got a sample of code that calculates the correct position of surface UI elements to make them look 3d like what you suggested.

I’d be happy to provide the code to you. But a fair warning the code is pretty bad :skull:

2 Likes

It’s a very nice module.

(my english is bad sorry. used translate)
It would be nice if you share the module in Roblox store.
And it would be nice to be able to enter cframe directly in the addface section instead of part and normal.
And I’m not sure if it’s possible, but when your part is a ball shape, it reflects it directly as a block. Maybe this can be done by using decal and editableimage.

2 Likes

I really like this! Thank you so much for making this and publishing it. It works great with a sci Fi type game!

1 Like

is there a way to have multiple Step Parameters?
I want it to work for the players and any part/model as well.

image

1 Like

unfortunately it’s not set up to work with multiple positions. what you could do is have multiple overlayed distancefade objects each with a different target position, though it might not have the intended effect

Thank you! You’re right, a much better version could be done with editableimages (I didn’t know about them when I made the module lol). Unfortunately I’m really busy with other projects and don’t really have the time to update it right now, but maybe down the line?

thanks! which folder are you talking about?

Sorry, I forgot to mention!

I’m using the HexagonBarrier template, I meant getting the children of the Model that all the parts are parented to so they don’t have to be individually listed in the script.

I’ve made a working prototype which implements parallax mapping to add a couple more options to the module, including a positional offset. And it looks pretty cool.



The download for the additions I made:
DistanceFadeParallax.rbxm (18.0 KB)
DistanceFadeHexagonParallax.rbxm (25.2 KB)

10 Likes

SO COOL!! i’ll link it in the post

3 Likes

The way the module’s set up AddFace needs to be called for each part, so you need to loop through the children to add them. You could make a function to simplify the process

local function AddFaces(model)
	for _,d in model:GetDescendants() do
		if d:IsA("BasePart") then distanceFade:AddFace(d, Enum.NormalId.Front) end
	end
end

Also in the hexagon template, each face has a different horizontal texture offset applied to it to make the texture seamless, which is why they’re listed out like that

1 Like

could you make it work for multiple instances?

you mean have multiple Runservice for different instances?

Hey, the hexagon module literally just doesn’t work for me. The local script is in StarterPlayerScripts with the module inside it, and the BorderObject is just a union in a series of folders in workspace. For some reason the module just doesn’t work at all. What did I do wrong?

I forgot the script:

local DistanceFade = require(script.DistanceFade)
local ForcefieldObject = DistanceFade.new()

local BorderObject = game.Workspace.MapObjects.Forest.Misc:WaitForChild("WorldBorder", 5)

local ForcefieldSettings = {
	["DistanceOuter"] = 36,
	["DistanceInner"] = 4,
	["EffectRadius"] = 20,
	["EffectRadiusMin"] = 16,
	["EdgeDistanceCalculations"] = true,
	["Texture"] = "rbxassetid://18852397345",
	["TextureTransparency"] = 0.65,
	["BackgroundTransparency"] = 0.9,
	["TextureColor"] = Color3.fromRGB(255, 0, 4),
	["BackgroundColor"] = Color3.fromRGB(255, 0, 4),
	["TextureSize"] = Vector2.new(20, 16),
	["TextureOffset"] = Vector2.new(10, 4),
	["Brightness"] = 3,
}

ForcefieldObject:UpdateSettings(ForcefieldSettings)

ForcefieldObject:AddFace(BorderObject, Enum.NormalId.Front)
ForcefieldObject:AddFace(BorderObject, Enum.NormalId.Back)
ForcefieldObject:AddFace(BorderObject, Enum.NormalId.Left)
ForcefieldObject:AddFace(BorderObject, Enum.NormalId.Right)

game:GetService("RunService").Heartbeat:Connect(function()
	local TargetPosition
	ForcefieldObject:Step(TargetPosition)
end)

it has to be a script w/ the Client on the RunContext

image