How to make Volcano Eruption Animations

Hello!
I’ve been wanting to implement a Volcano Eruption into my game, but i’ve hit a dead end on how to animate it.

I’ve tried using math.cos(x) but i’ve had some very weird results with it, i might be using it wrong.
I would like to know if anyone knows how to do something like this:


Imagine the green part is the volcano’s debris (or wth the name is) coming out of the Volcano.

Now i could use something like BodyVelocity but i think it might be weird to work with since i want these Debris to go into specific positions that could change when the Volcano erupts.

Here is a snippet of what i tried doing (It’s very bad code, but i was just testing lol):

local TweenS = game:GetService("TweenService");
local Alpha= 0
local B = workspace.B
local A = workspace.A;
local Duration = 4

task.wait(7)
local a 
a = game["Run Service"].Heartbeat:Connect(function(deltaTime)
	Alpha = math.min(Alpha + deltaTime / Duration, 0.4);
	B.Position = B.Position:Lerp(A.Position + Vector3.new(0, math.cos(Alpha * 3.14) * 80, 0), Alpha);
	
	print(Alpha)
	if Alpha == 0.4 then
		a:Disconnect()
		print("a")
	end
end)

simple solution will be to lerp from start to end and depending how close delta to 0.5, raise y of lerped vector

Could you provide an example of how i could do it?

local startpos = Vector3.new(10, 0, 10)
local endpos = Vector3.zero
local delta = 0

local function onHeartbeat(dt)
 delta = math.min(delta + dt, 1) -- make sure delta wont be greater than 1
 
 local lerped = startpos:Lerp(endpos, delta)
 local height = math.sin(math.pi * delta) * 10
 
 local result = lerped + Vector3.new(0, height, 0)
end
1 Like