isaac-mason / recast-navigation-js

JavaScript navigation mesh construction, path-finding, and spatial reasoning toolkit. WebAssembly port of Recast Navigation.
https://recast-navigation-js.isaacmason.com
MIT License
227 stars 18 forks source link

Crowd division #391

Open FrameMuse opened 1 week ago

FrameMuse commented 1 week ago

Description

I would like to see a crowd to divide when someone goes through it.

Visualization

Imagine you have multiple agents forming two groups image

And then someone decided to go to the point that lies through these groups. image

The behaviour I would like to see is these groups of agents would step off a bit to let an agent to go through image

And then close up again. image

Research

I already investigate and played with collisionQueryRange, obstacleAvoidanceType, separationWeight, updateFlags, but couldn't achieve the desired behaviour.


What would you suggest to do in such situation? I would also like to do this with multiple agents at the same time and having some of the agents to be fixed (but probably this simply destroying the agent and creating an obstacle). Though I would love to hear your opinions, thanks ^-^

isaac-mason commented 1 week ago

Hi @FrameMuse,

I'd need to look at how detour handles agent steering a bit more closely before I can answer this completely.

Agent velocity is influenced by a target velocity and an obstacle avoidance velocity.

You can debug these with:

If you're not able to tune obstacle avoidance parameters to get the behaviour you want, you may need to write some of your own logic for this. For example, you could pick a target or apply velocity for agents avoiding another agent, considering the other agents current path and position.

Regarding static agents, creating an obstacle with the size of the agent is a good approach. It should also possible to set agent parameters so that they won't move. e.g. set their max acceleration and speed to 0.

Please share how you get on with this 🙂 curious to hear what you come up with

FrameMuse commented 6 days ago

This is what my experiments results are:

So I will try to apply custom behaviour by checking agents in a radius, if someone is on the nextTargetInPath, I will apply acceleration to them perpendicularly a moving agent. Which should have the effect. But I have problems with that as when I use requestMoveVelocity, the target is resetting.


My "dream" is to make it very similar to what Company Of Heroes 1 or Supreme Commander 2 have.

isaac-mason commented 3 days ago

Thanks for sharing!

I believe using requestMoveVelocity overrides the "move request" set by requestMoveTarget yep. You would need to keep track of the previously set target yourself.

Keen to hear how you get on creating the custom behaviour.