- Home /
Question by
Jedich1399 · Sep 11, 2016 at 02:02 AM ·
javascriptnavmeshnavmeshagentduplicate
Duplicating NavMesh Objects
Heya. I have a strange problem. I've made a NavMesh object, and I need to dublicate it. But when I'm doing it, these objects are not moving.
There's a code of Nav Meshed Object:
#pragma strict
private var nav : NavMeshAgent;
private var target : Transform;
var attackDistance : float = 5.0f;
var seeDistance : float = 30.5f;
var idleAnimation : AnimationClip;
var walkAnimation : AnimationClip;
function Start () {
GetComponent.<Animation>().AddClip (idleAnimation, "idle");
GetComponent.<Animation>().AddClip (walkAnimation, "walk");
nav = GetComponent(NavMeshAgent);
target = GameObject.FindWithTag("Player").transform;
}
function Update () {
if(Vector3.Distance(transform.position, target.transform.position) < seeDistance){
nav.enabled = true;
nav.SetDestination(target.position);
GetComponent.<Animation>().CrossFade("walk");
} else {
GetComponent.<Animation>().CrossFade("idle");
nav.enabled = false;
}
}
Thanks for your help.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612092501im_/https://answers.unity.com/themes/thub/images/avi.jpg)