// Update is called once per frame private void Update() { if (_path == null) { return; } if (PathIsTraversed()) { _path = null; _currentWaypointIndex = 0; if (!_isClonedInCurrentShape) _prevOutDirection = _currentShape.GetOutDirection(_prevOutDirection);//получение направления выхода из текущей shape var prevShape = _currentShape; _currentShape = NodesGrid.GetNextShape(_currentShape, _prevOutDirection); if (prevShape != _currentShape) TryAddShapeToList(_currentShape); if (_currentShape == null || _currentShape.IsInRotateProcess || !_currentShape.HasConnection(_prevOutDirection)) { DestroySelf(); return; } _path = _currentShape.GetPath(_prevOutDirection); _isClonedInCurrentShape = false; _parentSignal = null; } bool isUpdated = UpdateCurrentWaypoint(); Vector3 moveDirection = GetMoveDirection(_currentWaypoint); if (isUpdated) { TryClone(); CorrectMovement(moveDirection); } Rotate(_currentWaypoint); Move(_currentWaypoint, moveDirection); }