void Update() { if (Input.GetMouseButton(0)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, LayerMask)) { if (hit.collider != null && hit.collider.CompareTag("Walkable")) { GridNode targetNode = AStarZone.GetClosestNode(hit.point); GridNode playerNode = AStarZone.GetClosestNode(Player.transform.position); Stack <GridNode> path = AStarAlgorithm.SearchPath(playerNode, targetNode); CharacterMovement.SetPath(path); } } } }