public void StartMoving(Vector3Int[] path, int pathLength, bool isAttacking) { this.path = path; this.pathLength = pathLength; this.isAttacking = isAttacking; // There is no path to traverse, move along to actions that occur at the end of moving. if (pathLength == 0) { MoveEnd(); } else { // Setting up variables which are needed to begin the movement. isMoving = true; Vector3Int unitPos = new Vector3Int((int)transform.position.x, (int)transform.position.y, 0); moveTimer = 0f; currentTileIndex = 0; movingPos = new Vector2(path[currentTileIndex].x, path[currentTileIndex].y); // This little logic (used later as well) swings the player's sprite a bit to appear somewhat funky! if (rotateBool) { endRot = new Vector3(0, 0, rotateRange); } else { endRot = new Vector3(0, 0, -rotateRange); } // Updating the direction and the walkability of our past tile. UpdateDirection(unitPos, path[currentTileIndex]); MovementManager.instance.UpdateTileWalkability(unitPos, true, null); // Spawns dust in the opposite direction to where we are going. Needs pooling! Vector2 startDustPos = new Vector2(unitPos.x + 0.5f, unitPos.y + 0.2f); Transform dust = PoolingManager.instance.GetObject(dustParticle, startDustPos).transform; StartCoroutine(dust.GetComponent <Dust>().DustMove(lastDirection * -1, dustDepleteSpeed)); // Update eye visuals. if (transform.CompareTag("Player")) { visuals.MoveEyes(lastDirection); } } }