- Home /
Navmesh: Check if agent destination can be reached
hi iam working on a puzzle game with several maze parts which looks like this one:
so in the beginning you have a randomly rotated maze and have to "un-rotate" each part/the whole maze by clicking on the parts:
the goal is to let the player run threw the maze (using navmeshes) as soon as the start and finish point is connected
but now comes the part where i am stuck. how can i check if the start and finish point is connected? so that the player starts to run as soon as it is possible?
currently the player just go wherever i click, even if its not possible, using this code:
using UnityEngine;
public class NavMesh : MonoBehaviour {
NavMeshAgent agent;
void Start() {
agent = GetComponent<NavMeshAgent>();
}
void Update() {
if (Input.GetMouseButtonDown(0)) {
RaycastHit hit;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100)) {
agent.destination = hit.point;
}
}
}
}
i guess i could do something like:
case NavMeshPathStatus.PathComplete:
but i dont know how i can combine and use this
Your answer
Follow this Question
Related Questions
How can I get available navmesh area? 0 Answers
NavMesh obstacles destroy 0 Answers
Nav Mesh Agent Type 3 Answers
NavMesh Agent rotates on X axis when moving and snaps back to 0. 2 Answers
Patchfinding Groups 1 Answer