# Linear Interpolation that is independent of frame rate

In this Tutorial (https://unity3d.com/learn/tutorials/topics/scripting/linear-interpolation?playlist=17117) , the last example is this:

```
> void Update () {
> light.intensity = Mathf.Lerp(light.intensity, 8f, 0.5f *
> Time.deltaTime); }
```

From what I understand, this code example does not do 50% interpolation per second.

How can I do a Linear Interpolation that is dependent on time (not frame rate) and is 50%?

Its in the $$anonymous$$anual! And answered extensively.

**Answer** by Bunny83
·
Mar 19, 2018 at 12:57 AM

Your use of lerp is **not** a **linear interpolation over time**. Time.deltaTime can only be used to compensate linear processes. Taking 50% of the remaining is not a linear process but an exponential process. This can not be compensated with a linear factor as each iteration has a different effect on the outcome. Linear functions have a constant derivative while exponential functions usually have an exponential derivative.

To actually calculate the factor needed every frame to achieve a 50% drop per second you would need to take the "n-th" root of "0.5" where n is the current framerate. For example at a framerate of 60 frames per second you would calculate the "60th" root of 0.5 which is about "0.988514". If you multiply a value by this factor 60 times you effectively have multiplied it by 0.5. However calculating the "1/deltaTime"th root of your desired factor is a quite expensive operation. Specifically using `Mathf.Pow(0.5f, Time.deltaTime);`

The example given on the page you linked is actually a really bad example usage for lerp. If you want a gradually slowed down interpolation from the current value towards a target you want to use Mathf.SmoothDamp just like they mention at the very bottom of the page you linked.

```
private float speed = 0;
void Update()
{
light.intensity = Mathf.SmoothDamp(light.intensity, 8f, ref speed, 10f);
}
```

Note that this will bring the intensity to the value of "8" within 10 seconds. Also note that the speed variable is controlled by the SmoothDamp function and is used to save the state of the velocity between frames. You shouldn't set this value manually. Just make sure you have an actual variable that persists between two frames.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.