Navmesh extension: stop movement of agents with different radii

Hi

Say you have a game with different types of units: infantry, tanks, etc. Units have limited view distance. OnEnemySpotted, AI actor needs to be able to stop movement. On top of that, the user interface must show unit movement paths.

Please do correct me if I am wrong, but this is not possible to implement with the current navmesh extension, is it? In other words:

  • The crowd controller cannot stop an agent once on its way.

  • The crowd controller can handle agents with different radii.

  • The navmesh controller w/o crowd controller can only handle units with the same radius.

  • I have no access to the path that is generated by the crowd controller after “agentGoto()”

  • The Babylon navmesh extension uses Recast.js which in turn is a wrapper around the C++ library “Detour”. Hence adding fearures means working with the c++ code (including a C++ dev environment…).

One workaround I can think of is using different navmeshes, one for each unit radius: I would get my path array and could send differently sized units. But this might be terribly inefficient (how to reuse navmesh??) and I would have to write my own crowd controller (ie reinvent the wheel).

I probably could just use a dummy TransformNode fed to addAgent() and then teleport the dummy agent back to the location where the real agent stopped. But no access to the path array**. Also this seems quite hacky. **Maybe I could poll the location of the TransformNode in the update loop. Even more hacky.

In effect, if I want my path, I will not be able to stop the agent. If I want to stop the agent, I will not get the path :s

So I am kind of stuck here and hoping some of my assumtpion are wrong and there is an easier way out.

Best wishes

Joe

Hey Joe!
I am sorry, I can’t help you directly with the default BabylonJS navmesh stuff, however @labris and me are working on BabylonJS examples for Yuka | A JavaScript library for developing Game AI

I was working on the navigation examples so I can lend you a helping hand with it. Check the YUKA docs, it’s really an amazig piece of software and so easy to use!

Here are the examples:
https://yuka.babylonjs.xyz/examples/js/navigation/

The GitHub repo will be available after we finish all the examples. It’s really something to wait for!

r.

:vulcan_salute:

2 Likes

Thanks roland for the pointer. Do you happen to know whether the YUKA pathfinder does handle agent size (ie radius in Recast) automatically?

Actually the behavior you are looking after can be implemented by another YUKA class/implementation. I suggest you to wait a bit for the BabylonJS examples release. I think it will cover all your needs. Meanwhile you can have a look at the YUKA docs or you can check the YUKA THREE examples to find the behaviors you are looking for.

The perception examples alongside the navigation will be a good start.

YUKA does not meet my requirements.

Returning to Babylon Recast, it would be awesome if anybody had any pointers in regards to the starting post.

The more I think about it, there has to be something wrong in my assumptions. What would be the point of an agent that cannot stop moving once on a path? So I am still hopeful. I am going to give it some time otherwise I will come back with any workaround I might have figured out.

Sorry to hear that.

Couldn’t be a solution to remove the agent when you want to stop him and add him back to the last position when you want to move him again?

cc @cedric

The crowd controller cannot stop an agent once on its way.

Did you try to call agentGoto with the agent current position?

The crowd controller can handle agents with different radii.

Indeed that’s possible.

The navmesh controller w/o crowd controller can only handle units with the same radius.

A navmesh without crowd can’t have agents at all.

I have no access to the path that is generated by the crowd controller after “agentGoto()”

It’s possible to have the path computed with the navmesh. Agents will try their best to follow it when taking into account avoidance and agent radius. See this PG : Babylon.js Playground

The Babylon navmesh extension uses Recast.js which in turn is a wrapper around the C++ library “Detour”. Hence adding fearures means working with the c++ code (including a C++ dev environment…).

Most of Recast features have been exposed. Do you have any feature in mind that’s missing?

2 Likes

Thanks Cederic for the clarification.

tl;dr: Hopeful that I can share some result soon('ish).

Did you try to call agentGoto with the agent current position?

Ok, now I feel kind of stupid…

A navmesh without crowd can’t have agents at all.

I appologise for the wrong wording. What I meant was when you query a path from vectorA to vectorB (via computePath(start, end)), then the query is constraint by the cs/ch parameters (link). You cannot change these parameters after navmesh creation. So this particular navmesh can handle an “imaginary agent” with sizes corresponding to the cs/ch parameters.

Most of Recast features have been exposed. Do you have any feature in mind that’s missing?

No, not really. The question was just to clarify my understanding as well as for potential options I have.

Anyway, thanks again for the pointers. That should get me somewhere :slight_smile:

1 Like

Dont’t worry. YUKA really seems to be a useful framework. I, and I bet others as well, have it on my radar!

1 Like

We can propose additions to the YUKA library. What do you miss?

tl;dr

stop movement of agents: as @cedric suggested

agents with different radii: not possible; one navmesh per radius

Long version

Here is my playground I have been working with: Babylon.js Playground Click on white cubes to select. Click on ground to move to.

Concerning the question re radii

We need to differentiate! You can query the navmesh without creating any agents: give me a path from 1 to 2. On the other hand, you can contract an agent via the crowd controller and tell it to go to target 2.

As far as I can tell from playground experimentation and Recast forum posts / github issues (did not study C++ sources though):

Recast bakes in one fixed agent radius at navmesh creation (via parameter walkableRadius). The ai agent radius parameter you specify in the crowd controller is relevant for

a) handling agent-to-agent collision (confirmed)

b) probably/maybe for corrective steering behaviour (though I could not replicate this in the playground)

Concerning the question re stopping an agent

I did not try it yet but @cedric suggested to just teleport the agent to the stopping vector. Chances are this is going to work as you also can reissue goto commands that interrupt the agent’s current path.

Yes, goto + teleport will stop the agent:

I set a time out that will stop the agent after 1 second.

Regarding the different radii, yes, it’s a limitation. You’ll need different navmesh (that’s not supported yet) but this can be done after Babylon 5.0 release.

2 Likes