- Home /
Question by
NerdRageStudios · Dec 09, 2014 at 11:28 AM ·
lerpfloatmathf
Using MathF Lerp on a float, please help!
Hi, I am using a camera script that controls saturation and there is a public float for the saturation slider 0 - 1f
So, I want to lerp to 0 when the player is almost dead, and lerp back to full when he has enough health, but for some reason I cannot lerp the float value as it always shows an error - 'float does not contain a constructor that takes 1 argument'
Here is the line I am trying to use:
colorCorrectionScript.saturation = new float(Mathf.Lerp(cameraNormalSaturation, cameraDamageSaturation, Time.deltaTime));
Can someone point out what I have done wrong please?
Comment
Best Answer
Answer by tanoshimi · Dec 09, 2014 at 11:36 AM
You don't need an explicit constructor, Mathf.Lerp returns a float anyway, so just this is fine:
colorCorrectionScript.saturation = Mathf.Lerp(cameraNormalSaturation, cameraDamageSaturation, Time.deltaTime);
Your answer
![](https://koobas.hobune.stream/wayback/20220613173618im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Mathf.Lerp not working as expected 2 Answers
Mathf.Lerp not working 2 Answers
How to update interval between objects in run time? 0 Answers