Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Rectangular agent?

Discussion in 'Navigation' started by modernator24, Jun 14, 2023.

  1. modernator24

    modernator24

    Joined:
    Apr 7, 2017
    Posts:
    184
    I have an issue with the tank character. The navmesh agent only has a cylinder shape, so when the enemies are nearby, it causes unwanted results. If the navmesh is too big(to cover the entire tank body), the enemies can't approach the side of the vehicle. If the navmesh is too small(only covering the center), the enemies pass through the front of the car and back. Putting the collider doesn't make any changes, the unity's navmesh agent just ignores whether it has a collider. How do I solve this problem? Any suggestions?
     
  2. Inxentas

    Inxentas

    Joined:
    Jan 15, 2020
    Posts:
    275
    The agent isn't a proper physics collider.

    Apply a NavMeshObstacle component to your tank. With it's "carve" options, you can put the shape of a box around your Agent which will carve out a piece of the navmesh as it moves around. This prevents the enemy from clipping into the tank. However, you will need to account for the edge case where an enemy is on the piece of NavMesh your tank carves away. You could count that as being ran over by the tank and destroy the enemy when it's (1) not on a mesh and (2) close enough to the tank.