Hello,
iam working on a puzzlegame where you have to rotate different maze peaces so that the player and the exit point are connected. so far so good.
iam currently working on the auto acknowledge to check if the way from the player to the exit is possible or not, if yes, let the player jump around.
if (path.status == NavMeshPathStatus.PathComplete) {
my problem now is, that the NavMeshPathStatus is reporting to early which looks like this in game:

so you see, the indicators is turning green even if the path is not complete and then it switches back to red because he realized that he made a mistake. pretty cute that he is so ambitious but useless ![]()
here is the complete code:
using UnityEngine;
using System.Collections;
using plyBloxKit;
public class NavMeshCheck : MonoBehaviour {
public Transform target;
public GameObject Ampel_Green;
public GameObject Ampel_Red;
public GameObject Attention;
private NavMeshAgent agent;
public bool Path;
void Awake() {
Ampel_Red.SetActive(true);
Ampel_Green.SetActive(false);
Attention.SetActive(false);
}
void Update() {
agent = GetComponent<NavMeshAgent>();
NavMeshPath path = new NavMeshPath();
agent.CalculatePath(target.position, path);
//GetComponent<Animation>().Play("Ball_Jump");
if (path.status == NavMeshPathStatus.PathComplete) {
Path =true;
Ampel_Green.SetActive(true);
Ampel_Red.SetActive(false);
Attention.SetActive(true);
//plyBloxGlobal.Instance.SetVarValue("Puzzle", false);
Debug.Log("PathComplete");
}
else {
Path =false;
Ampel_Red.SetActive(true);
Ampel_Green.SetActive(false);
//plyBloxGlobal.Instance.SetVarValue("Puzzle", true);
Attention.SetActive(false);
Debug.Log("PathInvalid");
}
}
}
the scene setup is pretty easy, on the floor is a navmesh, and if the level gets loaded some maze parts will get instantiated which inculding some navmesh obstacles. idea comes from here: http://forum.unity3d.com/threads/check-if-two-rooms-are-connected.331068/