Hello,
sorry for most probably a noob question, but I could not find similar problem anywhere. I am trying to lerp position and scale at the same time using the perc value. I have noticed that the position changes much quicker than the scale. When I changed the t value from “perc” to 0.1 in the position lerp. Object moves to the 0.1f position but then very quickly lerps to the end position again. This does not happen with the scale lerp. When I change the value to 0 or 1 there is no lerping. What is wrong ?
float lerpTime = 1.0f;
float currentLerpTime = 0.0f;
private bool lerping = false;
void Update()
{
if(lerping)
{
if (currentLerpTime < lerpTime)
{
Vector3 start = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z);
Vector3 end = new Vector3(145.0f, transform.localPosition.y, transform.localPosition.z);
float perc = currentLerpTime / lerpTime;
//transform.localScale = Vector3.Lerp(_initialLocalScale * (1.0f + _positionCtrl.centerBoxScaleRatio), _initialLocalScale * (1.3f + _positionCtrl.centerBoxScaleRatio), 0.2f);
transform.localPosition = Vector3.Lerp(start, end, 0.1f);
currentLerpTime += Time.deltaTime;
}
}
}
Thank you for your help !!