How do I ease this value?

Supposing I have a frame whose transparency I want to go from 0 to 1. I have function provided below to help me get there linearly. How would I go on about doing that w/ the provided function?

local function linear(t, b, c, d)
  return c * t / d + b
end

EDIT: Here’s a very useful resource for easing functions: Robert Penner's Easing Functions

1 Like

In that following function you have that equation that makes a linear ease, a linear ease is a type of ease, it is like a straight line that always goes with the same speed from the start to the finish. So we will go from a value to another at constant speed.
image

The word “linear” always refers to something constant or organized in a straight way in my opinion.

Anyways, in this equation you have 4 variables:
t is the current time or where we are in terms of the duration
c is the value delta aka the goal value
b is the start value
d is the duration of the tween

Let’s rename these values to make it easier
So if we do something like this.

local function linear(time, start, goal, duration)
  return goal * time / duration + start
end

print(linear(5, 0, 1, 10))

What we said here is, we want to linearly tween the value 0 to 1 that would be take 10 (seconds or whatever), but we wanna see what value we have if we just tween half the time.
Since we set time to 5, we just got what value we would get if we were at half the time. Technically this would print 0.5, because that is the value half way.
So if we wanna make it tween all the way from 0 to 1 smoothly. We would use a for loop and the i variable for a reason.

local part = workspace.Part

for i = 0, 50, 1 do
   wait(0.1)
   part.Transparecny = linear(i, 0, 1, 50)
end

You can see we set what time we are as i, and the duration as 50, which is also how much this loop is going to loop.

If you were to clear your mind and understand this, this loop is going to loop all the way from 0 to 50, with i being incremented by 1 each time.
So pretty much the first time it loops, i would be 0, and we would do 0 out of the duration which is 50, and then it loops again and i is 1 now so we do 1/50 of the duration. And then 2/50 and then 3/50… until we hit 50/50 and the tween is done.

I hope you unedrstood

Here is a great website having a lot of these equations

6 Likes

Thank you for the very succinct and elaborate answer.

1 Like

No problem! I hope you got this concept, there things sometimes that are impossible to explain with words, the leaner has to sum up in his mind.

I had a hard time grasping what the input values were because they weren’t descriptive at all. The websites you linked will come in handy because this was exactly what I was looking for, easing functions beyond what Roblox offered. Are there any other websites like the one you posted?

Not really sorry, you can just do some quick googling you can kind find something goood.