I don’t know how to stop update forcing my function to reset ‘t’ to ‘timetolerp’.
I understand the problem, what’s happening is the update function is calling my function(which is called within the unity lerp function in weather.cs to define t) and my t value in my function(Time.cs) is constantly reset because i’m declaring what t is then i’m subtracting it, but before it can get any smaller it is reset because the update function calls my function again and it has to.
I don’t know how to get around this because t in my function needs to be defined;
Time.cs
using UnityEngine;
public class Time
{
public static float LerpTFunction(float timeToLerp)
{
float t = timeToLerp;
t -= UnityEngine.Time.deltaTime;
Debug.Log(t);
return t;
}
}
Weather.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Weather : MonoBehaviour
{
public float Position;
public float Ttolerp;
public float PointA;
public float PointB;
void Update()
{
Position = Mathf.Lerp(PointA, PointB, Time.LerpTFunction(Ttolerp));
}
}