I’m using vector3.Lerp to move from one position to another,but the lerp time and moevement are not in sync as lerp varies from 0 to 1.
Here’s my code
Vector3 Target_Pos=new Vector3(0.18f,0,0);
float LerpTime=0.0f;
float LerpSpeed=10.0f;
void Update()
{
if(LerpTime<1.0f)
{
transform.position=Vector3.Lerp(transform.position,Target_Pos,LerpTime);
LerpTime=Time.deltatime*LerpSpeed;
}
else
{
Debug.Log("Lerp is finished");
}
}
But the object reached at position 0.18f in X before LerpTime reaching 1.0f.The object finished interpolation at a time near 0.05 to 0.1f,but the log will out only when the LerpTime variable reaches 1.0f which is areound 10 to 20 seconds after movement is finished.I need to log the exact time when the object reached its target position
Any help…?