Hello, sorry for my english grama, i try ma best. Im tryin a little bit to understand and learn the NavMesh system and got an problem with my enemyNavMeshAgent.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class EnemyFollowScript : MonoBehaviour
{
public NavMeshAgent enemyAgent;
public GameObject player;
void Start()
{
player = GameObject.Find("Player");
NavMeshHit hit;
if (NavMesh.SamplePosition(transform.position, out hit, 1.0f, NavMesh.AllAreas))
{
transform.position = hit.position;
}
}
void Update()
{
HandleFollowPlayer();
}
public void HandleFollowPlayer()
{
enemyAgent.SetDestination(player.transform.position);
}
}
Here is my Code and my problem is when i start the game and the enemy drives/comes to my players position he wont stop. hes drives through my playermodel and stick right to it but this only happens when the enemy comes with an certain amount of speed. When it comes with lesser speed to my players position he stops right at the moment he collides with it. i tried to play with the stoping distance or implemented it in code and not only in the agent it self but nothing helped. i thought the problem lies with ma enemy cause he got no ridgidbody but if i gave him one the enemy shakes like a maneac when he collieds with my player. the enemy need that speed cause a mechanic in my game should be to ram at eachother. hope someone can help me with my problem, thanks.