Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

What AI should I use?

Discussion in 'Editor & General Support' started by juliobds, Aug 11, 2012.

  1. juliobds

    juliobds

    Joined:
    Dec 27, 2011
    Posts:
    25
    Hello everyone,

    I'm developing a project that has a very extensive terrain. The terrain is actually infinite and is randomly generated. I'm at a point that I need to develop some better AI and, to get things moving faster, I'm looking for something that can be bought in the unity Store or similar.

    My terrain is composed of tiles of 2Km * 2Km and because it is procedurally generated it would be necessary to calculate the "walkable area" (Navmesh) at runtime. To complicate things even further I have buildings with multiple stores and the agents should be capable of entering buildings and coming out of them and then walking around (exploring) the terrain.

    The options that I know I have for sure are as follow:

    - AI 4 Enemies: Kind of works but I find it to not very optimized and the code is a mess. Enemies get stuck in the smaller little things.

    - CritterAI (CaiNav): It would be good enough but It doesn't work very well with large areas. How would I handle the AI moving from one tile of my terrain to the other? Do not forget that each tile of 2*2 Km is an independent navmesh.

    - Path (from AngryAnt) Do you guys recommend path? What are his limitations and should I use it? How is performance like and the "level of intelligence" of the agents? Is the navmesh baking process automatic or waypoint only?

    - UnitySteer: I tried this but the demos they had were awful. For example one of the demos was demoing the capabilities of sphere avoidance but with only 3 agents in the scene, they were colliding with the sphere many times per minute.

    - SimplePath: can only do path-finding in a grid (AFAIK). Because of that IDK if it has support to multi-store buildings, and how would I handle the agents moving from one terrain tile to the other?

    - Advanced Fantasy AI Pack: From what I've read about this pack, it's just a if-else confusion code wise and the performance doesn't seem to be that great. Apart from that IDK how the agents navigate the world.

    - A* Pathfinding Project Pro: I know nothing about this pack. Is it efficient? How does it calculate the navmesh? Does it support large terrains and multi-store buildings?

    - Rain{One}: This is probably what we will be using. We might have to create various waypoints at the border of the tiles to interchange the navmesh that is being used by the agent. The same thing might be done to buildings if the baking isn't all that great. Can anyone tell me if the navmesh baking in this AI solution doesn't have that many bugs? And that it can be immediately used without human interaction 99.9% of the times?

    Thanks in advance, if people have any more AI solution that may suits my needs I will consider it.
     
  2. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    This really depends on the game you are making, but why doens't the AI that comes with Unity work ?
    By AI I'm refering to the navmesh/navagent solution that is available there.
    With it, you can make a pretty solid AI , the navigation is done, the rest is just "IF" statements, and get a general brain working to control the smaller units, it doesn't take that long, I got mine working in 1 day or so.
     
  3. juliobds

    juliobds

    Joined:
    Dec 27, 2011
    Posts:
    25
    AFAIK It's not possible to create the navmesh while running the game at the same time. The Unity Navmesh can only be calculated in the editor and my terrain is procedurally generated (Both terrains, cities and buildings) so I need a solution that let's me create the navmesh while the game is running (think minecraft).

    Just so everyone can have an Idea of the scope of things here are 2 in-game screenshot:




    Also: Hey there Bruno xD We worked together a few years back.
     
  4. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    That's true, using the Unity navmesh everything has to be precomputed, it won't work on your situation., I believe in Unity 4 we will have the option to do this dynamically, but we need to wait and see, and if you can't wait, well, from all the solutions posted above I think I would go with the Advanced Fantasy one, I played around briefly with Rain{one} and didn't like at all the workflow they had there.

    Hey Julio., still playing Enigma7 ? :p
     
  5. juliobds

    juliobds

    Joined:
    Dec 27, 2011
    Posts:
    25
    From what I've read, Unity 4 will only implement dynamic obstacles and avoidance priority on top of what's already in Unity 3.5. So the new functions are great but I still end up having the same problem of needing to do the navmesh calculations at runtime.

    I would be grateful if anyone would also share their opinions.

    And BigB, I play Enigma7 everyday xD , also, congratulations on the release of Gemini wars and the recent update on ORCZZ. :)
     
  6. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,797
    I've used several of those and the A* pathfinding project has been the best to work with. Although I'm not sure if the pro version supports dynamic navmesh generation, perhaps contact the author?

    UnitySteer is great if you're keen to dig into the source, but it's obstacle avoidance is pretty much useless and it gets stuck, but you can of course change this as you have the code.

    SimplePath was a nightmare to work with when it came to instantiating and destroying agents, and the author didn't bother to reply to my very simple example project to help me with the issues I was having. So I wouldn't recommend that.

    You can always use a combination of libraries as well. In one game I worked on I used a combination of UnitySteer and A*
     
  7. Rico21745

    Rico21745

    Joined:
    Apr 25, 2012
    Posts:
    409
    I am currently using Aron's A* for my AI. My project will eventually have randomly generated terrains, so I have similar issues. I have a few ideas on how to deal with the problem. My initial thoughts are to instantiate grids dynamically as needed by agents. So if I spawn an agent in area X, I also create a grid the size of area X for my agents to navigate in. This could potentially turn into a big messy solution though, when you start thinking about "what happens if I'm at the edge of area X" and then you need to start worrying about stitching grids together and instantiating new ones as you get close to an edge.

    For the multi-story buildings, you could potentially use a navmesh + grid combination, but the will be a huge pain to stitch together I'm sure. I haven't dug much under the hood of the A* project, but I imagine this may be somewhat difficult to do.

    I'm actually very interested in the answer to this myself, as this is pretty much the same issue I'm facing later on. What's your project, if you don't mind me asking? Maybe we can help each other.