Hey guys, I have a square that i move by using this couroutine
private IEnumerator Move(int steps)
{
var shape = particleSystem.shape;
for(int i = 0; i < steps; i++)
{
if (canMove(dir))
{
isMoving = true;
shape.rotation = new Vector3(0f, yParts(), 0f);
particleSystem.Play();
float elapsedTime = 0;
startPos = transform.position;
targetPos = startPos + dir;
while(elapsedTime < timeToMove)
{
transform.position = Vector2.Lerp(startPos, targetPos, (elapsedTime / timeToMove));
elapsedTime += Time.deltaTime;
yield return new WaitForEndOfFrame();
}
transform.position = targetPos;
isMoving = false;
}
}
}
In editor it works fine, but on mobile movement isn’t smooth. It isn’t fps problem, because I have particles on the scene and they goes correctly.
I thought the trouble is that I am adding Time.deltaTime, but i’m doing it more often then Time.deltaTime. So I tried changed yield return null with yield return new WaitForEndOfFrame();. It makes better, but i don’t sure. Anyway result is different from the one in the editor. Will be pleasure for any help, and sorry if my English isn’t good.