it is not recommended to use tick() to do precise things like animations, it can cause nervous movements. Instead you should use dt.
in this case the velocity is multiplied to the time inside the sine function, but for this to vary it must also depend on time. It can be a linear or exponential dependence (which I think fits better) or any other.
local x = 8
local t = 0
local function onRenderStep(dt)
t += dt
local v = 1 + 0.3*t -- Lineal
-- local v = math.exp(0.2*t) -- Exponential
local angle = math.sin(x*t*v)
local eggCFrame = camera.CFrame * offset * CFrame.Angles(0, 0, angle)
egg:SetPrimaryPartCFrame(eggCFrame)
end
3 Likes
It does speed the egg but is there a way I can limit it’s speed?
Sorry, but is it supposed to be like this?
you should change the scale factor (that 0.3) slightly. Also change the value of x a little bit. If you prefer to use the exponential dependence you should change the scaling factor (that 0.2).
This is all you can do mathematically (unless you find a much better dependence function). If you still don’t like the results you should consider animating in parts or using the default Roblox animations. In the case of the video, it is in parts animation.
1 Like
Thank you very much! It works like a charm, but how can I give it a max speed?
simply truncating the speed
local v = math.min(1 + 0.3*t, 2)
that 2 is the maximum speed.
1 Like