public void Move() { location = location.Previous; transform.position = location.Value; if (successor) { successor.Move(); } else { location.List.RemoveLast(); } }
IEnumerator Move() { Vector3 direction = Vector3.zero; while (true) { direction = CalculateDirection(direction); if (direction != Vector3.zero) { Vector3 oldPos = transform.position; transform.position += direction * moveSpeed; transform.rotation = Quaternion.LookRotation(direction); movement.AddFirst(transform.position); successor.Move(); } yield return(new WaitForSeconds(moveTime)); } }