- Home /
AI code for enemy car to follow the player car
I use this code to my enemy vehicle to follow the player using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; public class AIcar : MonoBehaviour { private NavMeshAgent enemy; public Transform target; // Use this for initialization void Start () { enemy = GetComponent<NavMeshAgent> (); } // Update is called once per frame void Update () { enemy.SetDestination (target.position); } }
but the enemy is waiting for the player to stop and then it finds an easy way to get close to the player. I need the enemy to chase the player fast and efficient. What modification to the code do you think that would fix it
Your answer
![](https://koobas.hobune.stream/wayback/20220612134629im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Ai dodge bullets 3 Answers
Why do the AI get caught on trees? 0 Answers
What am I doing wrong with my AI? 1 Answer
Moving AI away or towards player not working correctly. 1 Answer
Make an object move towards a Player 1 Answer