0

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;
}

}

This is what it looks like

  • for some reason youtube is giving me just a spinning thing, and not showing your video.. maybe its still "processing" .. anyway, you should easily be able to find out whats going on, by debugging dir, and checking if the navmesh has a path, updating the navmesh every frame seems excessive, but I wouldnt expect it to wander off, only times Ive seen it wander off is when it cant reach the destination – BugFinder Feb 20 '20 at 21:51
  • your video finally loaded, Im going to guess they get knocked off the navmesh which is why they faff about on the edge and dont do anything – BugFinder Feb 20 '20 at 22:31
  • Does the player have some kind of ability that pushes the AI or is that included in the unwanted behavior? – LLSv2.0 Feb 20 '20 at 22:53
  • The ability to push is not wanted, do you know how to get rid of it. Also, they where getting knocked off the edge so thank you very much – WilliamM Feb 21 '20 at 02:59

0 Answers0