Search Unity

How to define a walk area for each AI type?

Discussion in 'Navigation' started by skinwalker, Feb 11, 2018.

  1. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    Hey,

    I have different creature types and I want to limit where they can walk while choosing their random waypoints.

    Beach creatures - can't go in the forest, can only pick a random goal that's in it's defined walk area.
    Forest creatures - can't go on the beach..

    I have tried building different navmesh surfaces for each AI type and marking areas as not walkable, but I imagine this will get pretty messy after awhile, since when you select a navmesh surface it shows all of the navmesh surface's colors on top of each others, making it really hard to see what's going on.

    I've also tried building an editor tool that makes a polygon and then the AI can only pick points from that polygon, but that doesn't mean the AI cannot go outside of that polygon while trying to reach a point if that path is the closest one. I also didn't manage to make this to the end, because I figured out while filtering which triangle to pick next (depending on AI position and direction) it will be a very slow algorithm, because I have an open world game.

    I am looking for suggestions and even assets on the store that will allow me to "draw" an area for each AI and it won't be able to pick a random point and step outside of that area.
     
  2. Miggi124

    Miggi124

    Joined:
    Jul 31, 2017
    Posts:
    69
    Hi,

    Quick answer here - try building separate NavMesh(es) for each creature, limiting which areas they can and cannot traverse.

    Try looking through this video for help.



    -Miggi124
     
  3. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    I have already tried that, the problem is that they are overlayed on top of each other's making it hard to see where each agent walks, because the colors are literally on top of each others. I started using A* Project and it has a built in feature that does that.
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I don't know how much Unity is still developing it, but what you're looking for is part of the NavMesh Components project:

    https://github.com/Unity-Technologies/NavMeshComponents

    Instead of using the built-in NavMesh baking, you add one or more NavMeshSurface component to an object, each of which bakes a navmesh for a different agent type.