How to make NavMeshAgent a trigger?
Asked Answered
N

2

0

I have a Nav Mesh Agent and a FPS controller. I want agent to follow FPS when Fps Enter a trigger…

I tried something but it doesn’t work

using UnityEngine;
using UnityEngine.AI;

public class hedefbul : MonoBehaviour
{
    public GameObject target;
    public NavMeshAgent agent;
  
    void OnTriggerEnter()
    {
        agent.SetDestination( target.transform.position );
    }
}
Nolasco answered 8/8, 2023 at 22:59 Comment(0)
A
0

I’m not sure if you ever solved this, but I’ve found some useful information here:

TL;DR:

Add a Collider and kinematic RigidBody.

Aloysia answered 24/9, 2023 at 14:42 Comment(0)
L
0

Collision detection occurs and messages are sent upon collision when:

Static Collider Rigidbody Collider Kinematic Rigidbody Collider Static Trigger Collider Rigidbody Trigger Collider Kinematic Rigidbody Trigger Collider
Static Collider
Rigidbody Collider
Kinematic Rigidbody Collider
Static Trigger Collider
Rigidbody Trigger Collider
Kinematic Rigidbody Trigger Collider

Trigger messages are sent upon collision when:

Static Collider Rigidbody Collider Kinematic Rigidbody Collider Static Trigger Collider Rigidbody Trigger Collider Kinematic Rigidbody Trigger Collider
Static Collider
Rigidbody Collider
Kinematic Rigidbody Collider
Static Trigger Collider
Rigidbody Trigger Collider
Kinematic Rigidbody Trigger Collider

Source:

Lotta answered 8/8, 2023 at 23:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.