public new void Move() { CalculatePath(); if (CurrentPath.Any() && CurrentPath[0] != null) { MoveToNeighborPos(CurrentPath[0].X, CurrentPath[0].Y); } else { SimplePath(); } base.Move(); }
private void Update() { if (Next.HasValue) { var targetPos = Map.GetCellCenter(Next.Value); if (Vector2.Distance(transform.position, targetPos) > 0.1f) { transform.position = Vector3.MoveTowards(transform.position, targetPos, Time.deltaTime * Speed); } else { Next = CurrentPath.Any() ? CurrentPath.Dequeue() : (Vector2Int?)null; } } else if (CurrentPath != null && CurrentPath.Any()) { Next = CurrentPath.Dequeue(); } else { Moving = false; } }