Search Unity

Duplicating NavMesh Object.

Discussion in 'Navigation' started by jedichchch, Sep 8, 2016.

  1. jedichchch

    jedichchch

    Joined:
    Sep 8, 2016
    Posts:
    1
    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:
    Code (JavaScript):
    1. #pragma strict
    2. private var nav : NavMeshAgent;
    3. private var target : Transform;
    4. var attackDistance : float = 5.0f;
    5. var seeDistance : float = 30.5f;
    6. var idleAnimation : AnimationClip;
    7. var walkAnimation : AnimationClip;
    8. function Start () {
    9. GetComponent.<Animation>().AddClip (idleAnimation, "idle");
    10. GetComponent.<Animation>().AddClip (walkAnimation, "walk");
    11. nav = GetComponent(NavMeshAgent);
    12. target = GameObject.FindWithTag("Player").transform;
    13. }
    14.  
    15. function Update () {
    16. if(Vector3.Distance(transform.position, target.transform.position) < seeDistance){
    17. nav.enabled = true;
    18. nav.SetDestination(target.position);
    19. GetComponent.<Animation>().CrossFade("walk");
    20. } else {
    21. GetComponent.<Animation>().CrossFade("idle");
    22. nav.enabled = false;
    23. }
    24. }
    Thanks for your help.