- Home /
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*/
}
}
}
Answer by cariaga · May 10, 2012 at 09:51 AM
ok i fixed the problem by replacing it with NavComponent.destination = Target.position;
Your answer
Follow this Question
Related Questions
Set navmesh destination if to object that is in range 1 Answer
Enemy looks for you, when he can't see you 1 Answer
A lot of navmesh agents affects ai accuracy 0 Answers
A* Pathfinding AIFollow in JavaScript? 0 Answers
Enemy Attack Animation 1 Answer