How would I prevent BillboardGuis from changing layering when camera is moved above/below them?

I am trying to create a custom particle system for viewing particles from far away using BillboardGuis. I am having this issue with the layering of the BillboardGuis.

https://gyazo.com/4a57859f38ebd4b573153b3efac8ae2c

Ancestry:
image

Another relevant image:

Script I am using to create these particles.


local FireCore = workspace:WaitForChild("FireCore") -- Part that the particles come out of

local Particles = {
	Fire1 = {
		Obj = script.Fire1,
		Height = 100,
		Lifetime = 20,
		Rotation = {-360,360},
	},
	Fire2 = {
		Obj = script.Fire2,
		Height = 100,
		Lifetime = 23,
		Rotation = {-360,360},
	},
	Smoke1 = {
		Obj = script.Smoke1,
		Height = 100,
		Lifetime = 30,
		Rotation = {-360,360},
	},
}

local function R(tab)
	return tab and math.random(tab[1], tab[2]) or 0
end

local function MakeParticle(Type)
	spawn(function()
		local ParticleData = Particles[Type]
		local Attachment = Instance.new("Attachment",FireCore)
		local ParticleVisual = ParticleData.Obj:Clone()
		ParticleVisual.ImageLabel.Rotation = R(ParticleData.Rotation)
		ParticleVisual.Parent = Attachment
		
		local ParticleTween = TweenService:Create(Attachment, TweenInfo.new(ParticleData.Lifetime),{Position = Vector3.new(0, ParticleData.Height, 0)})
		ParticleTween:Play()
		ParticleTween.Completed:Wait()
		Attachment:Destroy()
	end)
end

while true do
	wait(0.1)
	MakeParticle("Fire1")
	MakeParticle("Fire2")
	MakeParticle("Smoke1")
end

How would I prevent this from happening? Could I just change a property of BillboardGuis or would I have to do something with scripting?

1 Like

ZOffset
Determines the forward-backward render position of particles; used to control what particles render on top/bottom

https://developer.roblox.com/en-us/api-reference/property/ParticleEmitter/ZOffset

Not sure if this helps.

Additionally you could tween the object like a fireball that leaves a tail behind. That way the particles are laid out in a line.

I personally have them transparent so you can see all the particles no matter how they flip.

Gui’s also have LayoutOrder

https://developer.roblox.com/en-us/search#stq=LayoutOrder

This is not a ParticleEmitter, these are BillboardGuis.

Setting the transparency keeps all the particles visible, but still has the undesirable flipping changing the layering from moving the camera up/slow.

Changing layout order seems to have no effect to solve this issue.

Possibly LayoutOrder then.

https://developer.roblox.com/en-us/search#stq=LayoutOrder

Changing LayoutOrder doesn’t seem to effect anything to solve this issue.

The concept is still the same as for particles, using a Z offset. You are specifically going to want to use ImageLabel.ZIndex and LayerCollector.ZIndexBehaviour. Set the BillboardGui’s ZIndexBehaviour to global. Then, each time you clone the templated BillboardGui in MakeParticle, increment a number upward and set the ImageLabel’s ZIndex to that number. Topmost Guis will always render on top.

LayoutOrder is if you’re using any of the UI layout objects. It’s irrelevant. This would be apparent by reading its documentation page.

This does not seem to have solved the issue.

https://gyazo.com/1c24211dfdad192f4803e67d20d878ce

local CurrentLayer = 0

local function MakeParticle(Type)
	spawn(function()
		local ParticleData = Particles[Type]
		local Attachment = Instance.new("Attachment",FireCore)
		local ParticleVisual = ParticleData.Obj:Clone()
		local ParticleImage = ParticleVisual.ImageLabel
		ParticleImage.Rotation = R(ParticleData.Rotation)
		ParticleImage.ZIndex = CurrentLayer
		CurrentLayer = CurrentLayer+1
		ParticleVisual.Parent = Attachment
		
		local ParticleTween = TweenService:Create(Attachment, TweenInfo.new(ParticleData.Lifetime),{Position = Vector3.new(0, ParticleData.Height, 0)})
		ParticleTween:Play()
		ParticleTween.Completed:Wait()
		Attachment:Destroy()
	end)
end

Properties of the BillboardGuis:

1 Like

I have mine very transparent so that you can’t tell which is in front because they all blend together. Like flames on a candle. No matter what angle I look at it from, it’s always looking the same.

To me, that looks like a gigantic candle flame. I could be wrong but have you thought about just making it into a Gigantic candle flame? They also have wall torches too, maybe camp fires might work to check out too.

You can look at how other people have done their flames and smoke stuff and copy that.

Again I have no idea but that’s how I would do it. I love how my flames work. But they may not be able to work that way for you.

If it’s just flames rising into the air, that’s pretty easy once you see how others have done it.