What math function does this?

This is a math question, what function would do this:

Probably a ton of tomfoolery, there isn’t a standard math function to create a curve like that.
More piecewise

cubic growth, constant middle, and exponential decay.

1 Like

This could be achieved by combining easing functions.
There’s no specific built-in function for this though.

1 Like

I’m trying to use this to create a viewmodel bobble by lerping CFrames

Sine then
char filllllllllling

local function customEasing(t)
    t = math.clamp(t, 0, 1)
    
    if t < 0.6 then
        return 0.5 * (t / 0.6)^2
    elseif t < 0.9 then
        local x = (t - 0.6) / 0.3
        return 0.5 + 0.3 * (1 - (1 - x)^3)
    else
        local x = (t - 0.9) / 0.1
        return 0.8 - 0.8 * (1 - (1 - x)^4)
    end
end

Something like this?

logistic curves are slow and then fast
and then at the end is negated exponential

1 Like

This took me a while.
The closest function I could get (using 3 functions - sin, expo graph, -x^4):

1 Like

May need some love.

local viewmodel = workspace:WaitForChild("Viewmodel")

local t = 0
local spd = 1
local dur = 1
local playing = true
local base = viewmodel.CFrame
local off = CFrame.new(0, 0.1, 0)
local rs = game:GetService("RunService")

local function curve(x)
	if x < 0.6 then
		return (math.sin((x / 0.6) * math.pi / 2))^1.5
	elseif x < 0.8 then
		return 1
	end
	return 1 - ((x - 0.8) / 0.2)^2
end

rs.RenderStepped:Connect(function(dt)
	if not playing then return end
	t += dt * spd
	if t > dur then
		t = dur
		playing = false
	end
	local y = curve(t / dur)
	viewmodel.CFrame = base:Lerp(base * off, y)
end)

Think that is right now.

I actually don’t like using: rs.RenderStepped:Connect(function
Think that is a bit crazy myself.. this is just testing..

2 Likes

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