public void MoveToPosition(Vector2 position) { Vector2 offset = head.Position - position; TileSides newFromArrive = CalculateSideByOffset(offset); if (newFromArrive != fromArrive) { head.SetReadyToRotation(newFromArrive); } fromArrive = newFromArrive; head.MoveForwardChainPosition(position); }
// ------------------------ Movement ------------------- public virtual void MoveForwardChainPosition(Vector2 movePos) { Vector2 backPos = _transform.position; _transform.position = movePos; if (backTrainElement != null) { backTrainElement.MoveForwardChainPosition(backPos); } // define to need rotation if (nextRotation) { SetRotation(rotateDegree); nextRotation = false; if (backTrainElement != null) { backTrainElement.SetReadyToRotation(localFromArrive); } } }