- Home /
why doesn't my triggers work?
SO this is a basic nav script. I want it so when capsule(player) is "deployed" from one end of a level and goes towards a target, and when it gets close enough to a target is should stop and then I'll run other functions. The problem is that I can't even get the triggers to work. It shouldn't be calling my test function a bunch of times. Just the one time. public Transform target; public Transform enemy;
NavMeshAgent nav;
// Use this for initialization
void Start () {
nav = GetComponent<NavMeshAgent> ();
}
// Update is called once per frame
void Update () {
move ();
}
void move()
{
nav.SetDestination (enemy.position);
/*Vector3 fwd = transform.TransformDirection(Vector3.forward);
if (Physics.Raycast (transform.position, fwd, 10)) {
}*/
}
void OnTriggerEnter(Collider other) {
print ("Atttack()");
}
Comment
Your answer
Follow this Question
Related Questions
Navmesh Agent 0 Answers
NavMeshAgent not crossing over certain tiles 0 Answers
Using a navmesh agent as a character controller 1 Answer
Nav Mesh Agents Not working 0 Answers
Random Position on Nav Mesh 1 Answer