Question by
unity_YYoxtjdH92iNIg · Jan 26, 2020 at 08:29 PM ·
triggernavmeshnavmeshagent
Navmesh Agent trigger ?
İ have a navmesh agent and FPS controller.. i want to agent follow FPS when Fps Enter a trigger.. i tried something but it doesnt work..
here is my code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class hedefbul : MonoBehaviour
{
public GameObject target;
public NavMeshAgent agent;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void OnTriggerEnter()
{
agent.SetDestination(target.transform.position);
}
}
Comment
Answer by Heimlink · Feb 10 at 10:48 AM
I'm not sure if you ever solved this, but I've found some useful information here: https://docs.unity3d.com/Manual/nav-MixingComponents.html
TL;DR Add a collider and kinematic rigid body.
Your answer
Follow this Question
Related Questions
NavmeshDestination not changing. 0 Answers
NavMesh always makes player move at origin on startup 1 Answer
Navigatin Mesh agent works for ~10 seconds, then starts moving sporadically 0 Answers
Creating NavMeshAgent types at runtime 0 Answers
Are nav mesh agents not supposed to find the path when getting stuck in other nav mesh agents ? 1 Answer