x


i can't set destination, using AI Navmesh via raycast

/this must be applied to the AI with a NavMeshAgent/

private var NavComponent : NavMeshAgent;

var Target : Transform;

function Update () { var hit : RaycastHit;

//GetComponent().destination = m_player.position;//follow c# version

NavComponent = this.transform.GetComponent(NavMeshAgent); var up = transform.TransformDirection(Vector3.forward);
Debug.DrawRay(transform.position, -up * 10, Color.green);

if(Physics.Raycast(transform.position, -up, hit, 10)){//anything that gets hit including terrain Debug.Log("Hit");

  if(hit.collider.gameObject.name == "Player"){//specific that gets hit 
  Debug.Log("Hit player");

   NavComponent.Destination  = Target.position;/*problem here*/


  }

}

}

more ▼

asked May 10 '12 at 09:15 AM

cariaga gravatar image

cariaga
37 5 6 8

ok i fixed the problem by replacing it with NavComponent.destination = Target.position;

May 10 '12 at 09:51 AM cariaga
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3570
x983
x143
x18

asked: May 10 '12 at 09:15 AM

Seen: 1145 times

Last Updated: May 10 '12 at 09:51 AM