Anyone using EQS for AI ?

Hi,

Unity lacks something very usefull for AI that is Environment Query System, this is something UE4 provides by default :

Meanwhile, i started making a dynamic virtual grid system prototype for AI, it’s dynamic because each AI has it’s own grid that follows it’s movement.

The grid queries mainly :

  • position is reachable
  • position is cover for stand position
  • position is cover for crouch position
  • player in line of sight
  • another AI agent is near the grid unit
  • distance to player
    (planned will be to add environment tags like important position or specific cover tags)

And i got some bunch of behaviour and query methods to create any sort of AI, like agents firing player and avoiding firing on other agents while moving from cover to cover.

near AI debug :

line of sight debug :

The advantage of the system is it’s dynamic it is refreshed at some adjustable time intervall, and it can be used as a base for making AI or adding GOAP system for example.

You got a lot better characters movement and placement based on environment and other characters than using only using navigation and trying to find positions based on some conditions.

Some articles:
https://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf
http://apexgametools.com/learn/apex-utility-ai-documentation/apex-utility-ai-unity-survival-shooter/

Is there some other people using such AI system with Unity ?

Should Unity start extending it’s AI library and add new Classes like EQS for everyone ?

3 Likes

I remember using some sort of scoring system in UDK for AI, where i would pick a bunch of point in an area of the navmesh and give them score based on the same kind of condition you listed, sound similar at least.
I know Apex for Unity uses that same kind of scoring for it’s AI.

It’s kind of funny that I used the same debug overlay style, I had never seen other examples.

The code I have is not super fast - but you can scale it at will and it’ll still work. Right now each map (20x20) takes about 0.2ms to update.per frame. Nothing fancy there, just loop through all points, run ‘evaluation’ calculation and store output.

I run that through an astar process to path.

3112212--235294--2017-06-18_09-11-28.gif

I can scale up or down dynamically per frame, so if need be I can increase performance by using a lower resolution map, then using higher resolution only when more detail is needed.

I think this is usually called an influence map, querying it is really useful.

2 Likes

Yep, but it’s not free.

I think most people use grid with spheres because it’s the better way to visualize grid positions lol

Per map or per zone can be better than having a dynamic grid per agent as you will avoid recalculating the same grid points by multiple agents.
I think i’ll modify my system to have sub grids and call evaluation of subgrids depending on agents positions.

Did you made it for some game ? or it is only a prorotype ?

Each of my agents needs different view - each view has different opinion on what things are good/bad. Some could share maps if they have the same evaluation criteria, but I think this is not worth it. If performance gets bad, I can use lower resolution map or limit process to like 5-10 agent per frame.

This is for my game’s world map AI.

This sort of thing is not really fitting for space game AI which is what I’m working on atm, but I wrote something similar for my entry in the AI challenge, which unfortunately I wasn’t able to finish in time - basically line of sight in the pic but I also had an array with the obstacle boundary positions marked for cover purposes.

To have any kind of flexible AI you need to be able to read data about the environment, so basically I think something like the grid thing would be beneficial as part of Unity - but the problem is that 1. It’s easy to hit performance problems with this sort of thing 2. There are many different ways to approach reading the environment, and efficiently caching data, with different tradeoffs 3. Different games have different priorities and things that they can/can’t trade off for performance.

2 Likes

It’s based on a grid , so you could apply it to 3D and query around an agent AI what positions are free and where it can feet, or if another oject is in line of sight.

https://www.youtube.com/watch?v=6Tr_K551zvI

At least Unity should propose a base, something many games would benefit, actually there is nothing about AI (only in the asset store).
About performance and other technical aspects, it would be up to Unity to bring some flexible and scalable solution .You can have a multithreaded quering system that will perform at a constant rate all queries each agent would push to it.

Yep it costs more, but it’s simple in some way, for advanced FPS or TPS it makes a huge difference on how characters behave, and it would be a big help for beginners that does not know about AI or how to do it.
Calling a query to get the best position matching the AI needs is easy.

I wrote something similar for a pacman AI once. It basically created a grid based on distance from pacman, distance from ghosts, and the presence of pills. Then the AI did a basic A* search to figure out an optimal path through the maze. It did a pretty decent job of clearing out whatever maze you threw at it.

The big issue with Unity providing this by default is there are so many different games built with Unity, and there is seldom a one size fits all solution when it comes to AI.

It could be useful, but in 3D nodes can add up very fast, and especially around large dynamic objects it’s going to hit performance hard. When you have more than a couple of ships it’s going to be necessary to start trading off stuff for performance, and that’s where the problem is with a generic solution.

I’m still interested in making something like a grid-system or vector field for fast-paced games in obstructed environments, like Strike Vector, but it would have to be pretty highly customised for the job.

However on the whole, I do think it would be useful for Unity to make a grid system for AI, for fps/3rd person games or something like that. Doesn’t even have to be part of the core engine, but maybe in standard assets or something.

Could you do use implicit grid? 3d space tend to be sparser than 2d in game, there is a mean to aggregate a lot of cell into single cuboid, and have cuboid linked together. A single cuboid has implicit cell position, that can be hash without storing them implicitly, and every path are a single line inside (it’s convex). And if you have dynamic object maybe you could make teh cuboid variant of jump point search.

For now I’m convinced that for most space/air games it’s far more efficient to leave out global environment data and just do context-based individual pings of the environment, but there are situations where this just doesn’t work well at all.

To know whether things like jump point search would be a big enough efficiency to make a 3D grid an attractive idea for a generalised solution you’d have to run some tests.

1 Like

Someone used a cool solution to evaluate if a acover and it’s direction are valid againt player position without needing raycast, it’s only maths.

It’s UE4 tutorial , but you can translate it to Unity

He checks the player direction is in the opposite cover direction within some angle (75° for example), than he checks the player is at some minimum distance from the cover position. this works great without needing to call Raycast.

Another optimisation tips , is you can evaluate for example only 8 positions around some AI agent per second.
For evaluation you can use :

  • navmesh function to know if one of 8 points is in navmesh and can be reached
  • navmesh raycast to have some approximation if the player is in line of sight
    Still you can use raycast or sphere cast for evaluating line of sight if you prefer, if you manage to evaluate all points one by one frame after frame (or per time intervall) instead of evaluating all points in the same frame.

Another benefit of using position evaluating around an agent AI , is the agent won’t get stuck against others while moving, the agent will know if there is room and where to go.
This is can be used for any kind of game , like rpg with melee combat, the AI agents will circle the around the player player , and when there is no more room around the other AI will know it and will wait until some area gets free.

This library must been in Assetmarket !
I found some:

What bothers me is most AI packages don’t use cover computation check as some sheduler , most use Update() function and perform all cover points computation at same time when this is not necessary.
It’s less performance than using a sheduler spreading calculation on several frames Update() calls.

I thaught more people would code such systems, mostly used for tps or fps shooter games, but it looks like not a lot code it using a grid system lol

Anyway, the first plugin you found looks cool, however we don’t know if it’s a dynamic grid or pre calculated and if it uses frame independent calculation.

1 Like

I plan to develop a similar library for my game.

It should not be difficult and there is lot of infos in this thread :slight_smile:
Feel free to ask if you have some question and i could get some answer.

1 Like

Thanks @zenGarden :slight_smile:
I found a library that could possibly do such things. Only it needs to be completed for specific things.
This library: https://assetstore.unity.com/packages/tools/ai/a-pathfinding-project-pro-87744
And library have this: A* Pathfinding Project

It doesn’t have grid points system, visibility checks, sheduler for AI checkings , or request system to get the best points to move to. It’s a navigation library only, indeed it’s multi threaded and better than Unity navigation.

But i agree this is a good start lol

1 Like