Reputation: 1
When I hit the enemy(which has the navMeshAgent) with my player the enemy is sent to the corner of the map and fidgets. It is sent in the direction that the player pushes it in. I just want it to go to the player for now.
The code
{
GameObject playerPosition;
NavMeshAgent navMesh;
// Start is called before the first frame update
void Start()
{
playerPosition = GameObject.FindGameObjectWithTag("Player");
navMesh = GetComponent<NavMeshAgent>();
if(navMesh == null)
{
Debug.Log("Nav Mesh for enemy brock");
}
}
private void Update()
{
Vector3 dir = playerPosition.transform.position;
navMesh.destination = dir;
}
}
Upvotes: 0
Views: 603
Reputation: 1
Try to increase drag in rigidbody.
I had the same issue in similar setup and when navmesh agents collided with some objects they were behaving like in your video. I increased Drag = 5 with Mass = 1 and it works fine! I do not know if it's the right solution though.
Upvotes: 0