- Home /
Utility AI
Hi there.
I am just fiddling around and experimenting inside Unity now for over a week by trying to create something like an Utility AI. Over the months I have been busy with behavior trees and FSM.
Right now I am trying to recreate something that the awesome guys at Apex AI have made. Here's the video: https://youtu.be/jse_ZleruJU?t=24m29s
Like shown above, I am trying to create a grid where all the positions inside the navigation area are. These positions would change their score, just like Apex did, on the amount of monsters around the AI. (So the AI always moves towards the best suited position inside the area.)
Problem is, I couldn't find a lot about Utility AI on the internet and nothing about this kind of grid positions.. I hope somebody can point me into the right direction, so I can continue my work!
Thank you in advance, Patrick
Answer by Lahzar · Sep 16, 2016 at 11:40 PM
Hey Patrick,
I have tried to fiddle around with utility AI, but I have not really got into it yet. Still I think I have done what you're trying to do, in my own 'game.' I made a cover system based entirely on this document. It is not a generic solution, as the one Apex probably has, but it works nicely.
If you use A* pathfinding you don't have to generate any grid, as you already have one. With navmeshes you have to use fustrums and complex math.. stuff...
Utility Theory is just where your AI evaluates multiple options, score them based on a (weighted) preference, and select the option that gives the best score. In a nutshell.
Anyways, once you have the grid its not very difficult. You just run through a small selection of the closest nodes in the grid, and perform simple checks on them, like "is this node in the preferred firing range?" or "is this node dangerously close to an enemy?" etc. I hope you get the point with these terrible examples.
Then add a number (a tag in A*) to this node based on what checks are true or not. I would recommend using enums for this to keep track of everything.
You could also then add score based on things like time it takes to reach this node. Anything really. Have fun.
~ Angelo
Angelo, I thank you for your reply! Your response points me, I think, in the right direction where I want to head.
Like you said, and as I though, maybe it's better to use the A* pathfinding ins$$anonymous$$d of navmeshes. I'll fiddle around a bit. Thanks again!
Your answer
![](https://koobas.hobune.stream/wayback/20220612092732im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
nav mesh agent not following properly 0 Answers
Way to find closest point in a specific area on navmesh. 0 Answers
CS0246: The type or name space name ''NavMeshSurface'' plz some help 0 Answers
Navmesh Agent "move back" when player comes to close? 1 Answer
NavMesh.SamplePosition returns point outside the NavMesh 0 Answers