This is a turn based game I am testing from Unity. When I run it its fine in turn 1, in turn 2 it slows down and by turn 3 the character just stops moving. Apologies if this is an obvious issue but I would like to find a solution. I have already tried using FixedUpdate as well. I use MoveTowards in a while loop to move the character object.
Update()
{
if (turn == true)
{
Move();
}
}
Move()
{
pos = target.transform.position;
StartCoroutine(MoveOverTime());
IEnumerator MoveOverTime()
{
while ((transform.position - pos).magnitude > 0.1f)
{
transform.position = Vector3.MoveTowards(transform.position, pos, 0.3f * Time.deltaTime);
yield return null;
}
yield return null;
}
turn = false;
}