#DOTS Navigation with avoidance

1 messages · Page 1 of 1 (latest)

hallow hare
#

Hey I'm creating my game with DOTS and I don't manage to add a proper agent avoidance.
Considering standard NavAgents aren't available under ECS I tried many options to get a result, physics based avoidance, raycast, ...
The main Issue is that in each case my agents leaves the NavMesh.
I was wondering if anyone have some solutions for that?
I also searched for some other pathfinding algorithms like BOIDS but I haven't find how to do it with the NavMesh.

nimble night
#

Do you mean avoidance is pushing characters off the navmesh?

hallow hare
#

Yeah

nimble night
#

so the /easy/ solution is you need to move using navmesh so you can never escape it

#

normally physics colliders would stop you escaping but if you don't use physics then you need to walk along the navmesh

#

not sure what navmesh solution you are using, but recast, which is what most libraries use under the hood (unity/unreal) have a method called MoveAlongSurface

#

now this does mean that your avoidance + movement are fighting

#

your avoidance has no idea about your navmesh bounds so might try push it out and your navmesh prevents it so you can get into a bit of a stuck loop in tight spaces

#

the hard solution is you need to include your navmesh inside your avoidance - the edge of the navmesh is something that should also be avoided

#

for me, i use orca (more commonly referred to as rvo2) for my avoidance which uses velocity lines

#

so apart from adding a velocity line for all agents, i generate polygones for the edge of the navmesh and pass in the nearby segments of these as velocity lines

#

this way my creatures also avoid the edge and play nice

#

now this isn't easy

#

i hacked away at this for 2 years before getting it working how i wanted (though a lot of this was building my own navmesh api for entities)

#

and tbh it isn't needed for most games, moving along navmesh (rather than just setting transform) is good enough for most games

#

at least with clever design

hallow hare
nimble night
#

yeah my issue was basically unity internals of recast are all hidden / inaccessible

#

so i wrapped and reimplemented the whole thing recast library

#

took so long mopSleep

hallow hare
#

How do you even do that?

nimble night
#

recast (+ detour) is a public library

#

it's what both unity + unreal navmesh solutions are based on

#

(though as unity's implementation is within the engine, it's unknow what if any modifications they've made)

hallow hare
#

and are there any samples on how to re-implement it?

nimble night
#

no

#

it's a huge job, don't recommend 😄

#

unless it's something you really want to do

hallow hare
#

The thing is that the navmesh works well under ECS but I'm missing that avoidance I'm looking for.
And I haven't found any suitable solutions.

nimble night
#

there are probably good alternatives

hallow hare
#

ok I see, but this problems will appear again I guess, how do you ensure Agents stays on the navmesh while avoiding each others?

nimble night
#

main reason i wrote my own navmesh was so i could get the raw data and generate a polygon around the edge

hallow hare
#

😭

nimble night
#

but it's not needed, i've done this without that

#

and yeah i just use the move method instead of setting translation so it can never leave the navmesh

hallow hare
hallow hare
cobalt cedar
hallow hare
nimble night
#

you don't really need 3d though unless you're a space ship kind of game

#

most '3d' games still only collide along the xz planes

#

and you can handle floors of buildings etc by filtering by the y plane on the nearest neighbours

hallow hare
nimble night
#

Cool package but won't work in burst as they've unfortunately wrapped managed

hallow hare
#

ok I see, but I'm still a bit confused on how I am supposed to handle heights with RVO2.
I have a game with multiple floors and at each floors you can climb on obstacles.
How should I proceed?

#

Filtering by Y plane as you said I guess, but I don't really see how to handle that.
Do I need to create a navmesh per height or something like that?

nimble night
#

navmesh works fine for this

#

here sec

#
// The agents cannot collide if they are on different y-levels.
// Also do not avoid the agent itself.
// Apply the layer masks for agents.
var isNeighbour = neighbour != agentIndex &&
    math.min(localElevation + agent.Height, otherElevation + otherAgent.Height) >= math.max(localElevation, otherElevation) &&
    (agent.CollidesWith & otherAgent.Layer) != 0;```
#

this is what i do

#

ignore agents that y + heights don't overlap

hallow hare
#

ok I see, and do you also handle slopes?

nimble night
#

navmesh handles slopes

hallow hare
#

oh

#

didn't knew that

nimble night
#

navmesh works on stairs/steps and everything

hallow hare
#

oh yeah I thought we were speaking about the navigation with RVO2 my bad.
I'll try to get something working and reach back thanks.

hallow hare
#

ok so I managed to get RVO2 working with UnityNavmesh.
I was wondering if you could give me some tips on how to "dynamically" insert navmesh bounds into RVO2 and how to setup thoses velocity lines?

#

I'm a bit lost on how I should proceed.
I've saw that I can use NavMesh.CalculateTriangulation to get the data I need from the Navmesh but I was wondering if I should create obstacles based on this data or modify the RVO2 calculations to include theses lines.

hallow hare
nimble night
#

that's the reason i wrote my own

#

i don't use the triangles

#

i use other data internal to the generation