How to make particles hover up and down?

I am trying to make particles constantly hover up and down for about 20 seconds. I figured out that I needed to use acceleration to allow them to move up and down, but the particle goes up, then not as much down, then back up. I understand this is due to the down acceleration having to slow down the up acceleration, but I wanted to know if there is a fix. Here’s my code.

while true do
	particleEmitter.Acceleration = Vector3.new(0,0,0)
	
	particleEmitter:Emit(150)
	
	local sign = 1
	for i = 1, 10, 1 do
		particleEmitter.Acceleration = Vector3.new(0,moveAmt.Value * sign,0)
		sign *= -1
		task.wait(2)
	end
end

Here’s a video of what it does.

Thanks in advance.

I got something working but don’t know if it’s what you wanted.

local particleEmitter = workspace.Part.ParticleEmitter
local amplitude = 100

local duration = 20
local startTime = tick()

particleEmitter.Rate = 0
particleEmitter.Enabled = true

while tick() - startTime < duration do
	local elapsedTime = tick() - startTime
	local progress = elapsedTime / duration

	local yAcceleration = math.sin(progress * math.pi * 2) * amplitude

	particleEmitter.Acceleration = Vector3.new(0, yAcceleration, 0)
	particleEmitter:Emit(1)

	task.wait()
end
particleEmitter.Enabled = false

After looking at the video again, I think the effect I created wasn’t how you wanted.
Instead of using ParticleEmitter.Acceleration, we can just tween the part itself and use ParticleEmitter.LockedToPart = true

Here’s a video of my new attempt

local Workspace = game:GetService("Workspace")
local TweenService = game:GetService("TweenService")

local part = Workspace.Part
local particleEmitter = part.ParticleEmitter

local AMPLITUDE = 32
local DURATION = 20
local AMOUNT = 150

particleEmitter.Speed = NumberRange.new(0)
particleEmitter.Rate = 0
particleEmitter.Lifetime = NumberRange.new(20)
particleEmitter.LockedToPart = true
particleEmitter.Enabled = true
particleEmitter:Emit(AMOUNT)

local tweenInfo = TweenInfo.new(DURATION / 2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local upTween = TweenService:Create(part, tweenInfo, {Position = part.Position + Vector3.new(0, AMPLITUDE, 0)})
local downTween = TweenService:Create(part,tweenInfo, {Position = part.Position})

upTween:Play()
upTween.Completed:Wait()
downTween:Play()
downTween.Completed:Wait()
particleEmitter.Enabled = false
particleEmitter:Clear()

You just cooked, i never thought of that, thanks!

In the future, if your particle has an aspect ratio of 1:1 with a resolution divisible by 8, use the Flipbook feature in the mode PingPong.

ParticleEmitter | Documentation - Roblox Creator Hub

I’ve never needed it myself so I’m not 100% how it functions but I think it’s a simpler way of achieving the effect. It requires no scripting which is best for performance.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.