Going off of what Ben said, it seems you don’t really understand what Lerp does.
I’ll try my best to explain it, as I didn’t fully understand it until recently.
When people talk of Lerping something, they mean to move an object from point A to point B over t Time, where t DOES NOT equal the actual “arrival time.” t Will NEVER equal the arrival time, and will always be between 0 and 1. 0 is the start, and 1 is the end. (You need division here)
I’ll use “arrival time” a lot in my explanation, but just know that arrival time means the total time that you want the number to go from its’ start to its’ finish (or its’ 0 to 1)
I’ll post my gravity script as an example:
IEnumerator Lerp_CurrentGravity()
{
_gravity.currentGravity = 0;
float totalTimeDelta = 0;
// Gradually Adjust Gravity
while (_gravity.currentGravity < _gravity.maxGravity && GetGravityState() == Gravity.State.Falling)
{
totalTimeDelta += Time.deltaTime;
_gravity.currentGravity = Mathf.Lerp(_gravity.currentGravity, _gravity.maxGravity, totalTimeDelta / _gravity.timeForMaxGravity); // Lerps the gravity
yield return new WaitForSeconds(Time.deltaTime);
}
if (GetGravityState() != Gravity.State.Falling)
_gravity.currentGravity = 0;
}
Look inside the While loop and you’ll see a totalTimeDelta float. That represents the total time that you’ve been “falling” in this instance of my script.
Now if you know that your actual “arrival” time is 2, then you’ll need to do the operation:
(totalTimeDelta / 2), which will give you an answer between 0 and 1.
This works for every sort of Lerping because its’ all based around the same principal.
WHAT YOU’RE DOING:
You’re setting the Lerp value directly to 1, which, is exactly the same as saying “Finish Lerping.” You might as well use transform.rotation = new Quaternion(x) at that point.
All im trying to accomplish in this code is for the object to return back to the same rotation value as the other object...like the x,y,z rotation values....i need my object to return to those values over a certain period of time...im just having trouble finding the right tutorial for my problem.
– TheWhaleDevnevermind i figured it out by putting time.deltatime for t...it worked just as i hoped...thanks anyways for trying to help me
– TheWhaleDev