Hi there Folks, I really need a little help in that part of the code, I’m with an object that is constantly moving in position Z forward, and I need to move it in position X without it losing speed. But what happens is exactly that, when he uses Lerp, it loses speed for a few thousandths of seconds and ends up creating a strange and really annoying effect…
private IEnumerator Move(int whereToMove)// 0 Up ; 1 Down- ; 2 Left ; 3 Right
{
switch (whereToMove)
{
case 0:
break;
case 1:
break;
case 2:
isMoving = true;
runTime = 0;
startSlimePosition = transform.position;
endSlimePosition = new Vector3
(startSlimePosition.x - 2.80f, transform.position.y, transform.position.z);
while (runTime < runDuration)
{
runTime += Time.deltaTime;
transform.position = Vector3.Lerp
(startSlimePosition, endSlimePosition, runTime / runDuration);
yield return null;
}
isMoving = false;
break;