I am made a script where a Zombie(object) is targeting nearest victim(Target).Code works for now.Now i write a script to destroy the pathway between zombie and victim in run time so zombie will find another path.But when i run the code, bridge got destroyed when i clicked but zombie still can walk on empty space and catch victim rather then finding alternative path.
What i found that destroying bridge only remove that object but navmesh still there.so i need a script so that bridge & navmesh both destroyed.
I used this script to destroy bridge >>>>>
#pragma strict
function Start () {
}
function Update () {
if (Input.GetMouseButtonDown(0)) {
Debug.Log(“End here”);
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit)) {
if (hit.collider.tag == “destroyable”) {
Destroy(hit.collider.gameObject);
}
}
}
}