NPC stops movement (i use AiPath + RVOController/RVOSimulator)

  • A* version: [5.2.4]
  • Unity version: [Unity 6 - 6000.0.26f1]

I’m new to A* Pathfinding and would appreciate any help.
I’m creating the npc’s for a restaurant, the positions they move to are the area where they can order food, a waiting line, the chairs and return to the spawn point so can return to the objectPool.

In AstartPath I set the path with RecastGraph and added RVOSimulator so that the NPCs do not overlap.

For the movement of the NPCs I am using AIPath and RVOController so that it can work with RVOSimulator.

NPCs are the customers of the restaurant, and can order food, sit down to eat, and leave the restaurant (For testing I only set them to be able to sit in the first 4 chairs on the right).
The problem is that at some random moment it stops walking completely before reaching the assigned destination.

The points I want them to go to are drawn with gizmos.
I’m new and I don’t know if this is failing because of a bad configuration on my part or because I’m not using the right variables to interact with AiPath:

  1. To assign the destination point that NPC should reach use aiPath.destination = destinationPosition;
  2. To check if I have already reached the target position I use aiPath.reachedDestination == true
  3. When the NPC has reached the destination position I stop it with aiPath.canMove and also stop the rotation with aiPath.enableRotation, then I rotate the transform so that it faces a specified point on the destination and end the walking animation to activate the idle animation.

Since I’m testing the behavior of the NPCs, I configured them to generate a new customer every 2 seconds and when they reach the order area of ​​the restaurant or are seated after a certain amount of seconds they automatically move on to the next state.
I still don’t understand what could be generating the error. For this type of behavior, can AiPath be used or is it advisable to use another component? :thinking: :thinking: :thinking:

I appreciate your patience, help and any suggestions.

You should be able to use AiPath for this without issue, yeah. That’s weird- they all just suddenly stop pathfinding at once? Can you show us the relevant part of the StopMovementCharacterNPC method that stops them? Also can you send a screenshot of one of the AIPath components when they suddenly stop? Having the Debug Info expanded would help too :+1:

The next image shows the code:
In UpdateCheckIfReachedDestination() it checks if it has already reached the destination position to execute StopMovementCharacterNPC() where it executes the Idle animation, deactivating the movement and rotation of the AIPath.

In the next video I pause it when an NPC stops completely to see the inspector in debug mode.

AIPath in the inspector in normal mode and in debug mode.

A* in debug mode.

1 Like

Okay gotcha, thanks for that info. I’ve been digging into this, and I have a few questions:

  1. So you’re stopping them manually when they’ve reached their destination, then you’re manually un-stopping them when you want them to move again? And you’re doing this so that you can place an obstacle over them right?

  2. What makes them an obstacle after they stopped? Are they tagged in some sort of way that will carve the mesh or anything?

  3. Does this happen when you have RVO disabled on all your agents as well?

When the npc character reaches its target I disable movement and rotation with (AiPath.canMove = false and AiPath.enableRotation = false) so that it cannot move or be pushed.

For the new tests I recorded I commented all interaction with AiPath except AiPath.destination and AiPath.reachedDestination which are the most important.

For testing I assigned an npc to spawn every 1 second.
When I run the test with the RVOSimulator Disabled component, they do not stop and reach their target correctly, all the NPCs that could spawn in the test do so correctly.

When I run the test with the RVOSimulator Enabled component the problem occurs.

Note: NPCs have the mesh on the Default layer and have no colliders.

Well that’s weird .-. Are your AIPath components on objects that are parented to anything? Feel free to drop a project file of this and I can poke around, if you’d like.

I created a project but removed most of the things that are not necessary to analyze the problem, mainly because they are a large number of scripts that would make the project difficult to read.

I uploaded the project to drive, if you can please tell me what your email is so I can give you access or send me a private message even though I am new to the forum and I don’t know if can send private messages. :thinking: :thinking:

The scene is Base_WhiteBox and in the scene ObjectPoolingManager is responsible for spawning all the NPCs and NpcCharactersClientsManager is responsible for indicating to the NPCs the destination of their movements.

The next videos are the behavior in the simplified project:

Tables and chairs are spawned with another system, in itself the objects that are involved in indicating the movement destination are: NpcCharactersClientsManager.cs is the one that has the information of which points are occupied and which are available to be occupied by an NPC and EntityNPCCharacter.cs which is the one that has the AIPath.cs class to assign the destination.

Thank you very much for helping me, I really don’t understand what causes it but I trust that it is some small detail that I haven’t found.

Glad to help :slight_smile: I sent an access request with the note that I’m from Astar Forums :+1:
Thanks for putting this together

Thanks, I’ve already given you access to the project

Turn off “Stop when destination is crowded”. That keeps them moving on my end as far as I can see. This would also explain why it works when RVO is off.

There’s some more information about RVO Density Settings for AIPath here. But yeah let me know if this helps on your end?

Is the proper way to disable it to have the first enabled parameter equal to = false?

Yeah I’m pretty sure that should be fine :+1:

Thanks a lot for the tip, now they definitely don’t stop when there is another NPC in their path, in the NPC initialization I added the next code

aiPath.rvoDensityBehavior = new Pathfinding.RVO.RVODestinationCrowdedBehavior(false, 0.5F, false);

I’m wondering if there’s any tweak I can make so that NPCs don’t enter areas that aren’t in AstarPath zones with RecastGraph

I performed multiple tests and they enter areas that are not blue, which is the gizmo where AIPath can navigate. Do I need to add an extra configuration? :thinking: :thinking:

For AIPath you may want to look into constrainInsideGraph :slight_smile: If that doesn’t yield good enough results let us know :+1:

Thank you very much :raised_hands::raised_hands:, that totally fixes the problem, now it doesn’t go out of the RecastGraph areas anymore, in fact now it recognizes tables and chairs to go around them much better.

I apologize for so many questions, I know there are a lot :sweat_smile:, I’m new to A*.
In the following video can see that NPCs sometimes collide with a piece of furniture and don’t recalculate a route in which they can go around the object or other characters, it happens sometimes in the order queue or at the end of the video can see how a character can’t sit down until he is slightly pushed by another player.

Note: the chairs have a small walkable area in front of them so that NPCs can get to them and perform the sitting animation.

1 Like

Not a problem, I’m here to help :slight_smile:

Huh, yeah, they’re just walking directly into the back of the chair, which is doubly weird because his path is behind him. I’m wondering if adding a small Funnel + Radius modifier would help? Maybe they’re just too close to the wall?

I tried all the modifiers and for the most part I got similar results to FunnelModifier or RadiusModifier.

FunnelModifier:

RadiusModifier:
In Test 1 you see the complete behavior of many characters entering the restaurant and receiving the food.

In test 2 I cut out the part of another test where the problem occurs when colliding with another NPC or a piece of furniture.

Excuse the dumb question here, but can you break down the issue you’re seeing in these videos? Is it just their movement being super second-guessy and not working well with each other? From the outside they look like they’re working just not super “cleanly” right now. That correct?

NPC movement has really improved a lot, in fact I think it’s pretty good except for a few details:

  1. In video test1 can see how a character in the order queue takes a curious route, everyone arrives directly but he makes a redundant turn even though he had actually passed close to the destination point before. (Can see the first 20 seconds, in the rest of the video there are similar behaviors.)
  2. (In video test2) NPCs often get stuck behind chairs and don’t turn around to find the path. (The gizmos indicate that they have found the path correctly but it’s as if they didn’t follow it)
  3. When the characters get the food they go to look for the chair to sit on, but as other NPCs are going to occupy the ordering area it is as if they bump into each other and do not go around.
  4. At certain times, although it is less common, there are characters who go to sit down but their route indicates to pass between the chair and the table and it can happen that an NPC who was going ahead sits on that chair and the other NPC is left pushing.

I know they are details because the movement has improved a lot, but they are details that make the NPCs seem somewhat clumsy at certain times, I was wondering what could solve this problem, if it is the current configuration I have in AIPath or if I have to modify the AstarPath configuration or adjust the 3D to make it work better. :thinking::thinking:

Gotchaaa :slight_smile:

Hmmm yeah I think a few things I would do here are:

  1. Possibly increase the Character Radius setting in your graph so that the edges are less close to the wall?
  2. Play with the radius of the AIPath units themselves. This may help with the RVO in general and let them keep a better distance from each other.

I think this is the “nailing down the settings” part that takes a lil bit of time to get through. Just figuring out what you can tweak and change slowly- start with those and let me know if they help? If not I definitely don’t mind fiddling through settings and ideas to get better performance out of your agents :+1: