public void MoveWithClick() { if (PauseManager.isPaused || PauseManager.isInteracting) { return; } if (Input.GetMouseButtonDown(0)) { Camera camera = IsometricCamera.Camera; RaycastHit hit; Ray ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 100.0f)) { //NavMeshAgent agent = GetComponent<NavMeshAgent>(); //agent.SetDestination(hit.point); NavMeshHit navHit; int walkableMask = 1 << NavMesh.GetAreaFromName("Walkable"); if (NavMesh.SamplePosition(hit.point, out navHit, 1.0f, walkableMask)) { NavMeshAgent agent = GetComponent <NavMeshAgent>(); agent.SetDestination(hit.point); MarkerManager.GenerateMarker(hit.point + new Vector3(0, 0.1f, 0), Quaternion.identity); } } } }