Obstacle and pathfinder in one object

Hello

Tell me how to make an object simultaneously be an object that searches for a path and can be an obstacle?

For example, there are several players on the stage and they need to find a way to the place where the cursor points, but it is also necessary that these players do not collide or pass through each other, they need to go around each other.

The event “Push away is not suitable” because it is necessary for players to go around each other.

What have you tried? You can assign both behaviors to an object. You might need to disable the obstacle pathfinder behavior of the object being moved prior to trying to move it. The player may see itself as an obstacle otherwise. You could then reenable it afterwards.

Constantly refreshing a pathfinder can use a lot of resources. You could probably reduce it by checking for distance between players or maybe between moving players. Depending on the complexity of your scene, you may need to find ways to reduce the updates to a minimum.

I tried using two behaviors at once.
If the player moves towards the “obstacle” object, he goes around it, and if towards the player with two behaviors, the player goes right through the player


How often were you triggering the pathfinder move action? It takes a sort of snapshot each time, it creates a list of nodes or path . It then follows that path. If another player is moving then the path needs to be updated as often as needed. Otherwise, the player would just continue on the path.

I’ve always wanted a way to check if something is in the path. I want to test using the nodes list with a ray cast. It might not help you but it made me curious. Do a ray cast from one node to the node plus 1.

How do I do this? Can you give me more details? I don’t understand.

What is the process? Do the players take turns or can multiple players move at the same time?

If objects are always moving then you would need to trigger the pathfinder move action on every frame so it updates the obstacles.

As far as optimizing, it depends on your project. Can you share more details of what happens?

  • Players can move simultaneously
  • Tell me how to start the movement action in the navigator on each frame?
  • The project has players (red cube with an arrow), obstacles (Blue cubes), and there will also be enemies

To run it on each frame, it just needs to be on an event without any conditions. If you move the players to a position based on a mouse click then you might need to save that position in variables. And then use those variables for the destination.

I wouldn’t recommend starting a new path on each frame unless the scene is fairly simple.

You could probably do something that checks the distance between objects and only “refresh” the path when the objects are close.

How can a point saved in a variable help to get to it without colliding with another player?

Have you tried using the Boids behavior as a substitute for pathfinding?
image

Here’s an example. I used 3 instances of a player object and I moved the object with the animation number 0.

IDK if its the best way or will work for your situation. But, in my test it worked. It should work the same for objects in a group.

I used the pathfinder draw behavior. Player 1 went around the other players. All the objects had both behaviors.

I tried to do as you advised.

It works, but not as I would like

If one player is standing still and the other is moving in his direction, then it works.

If they both move towards each other, then it does not work and they pass through each other.

If they both point at the same point, then they merge into one, it is impossible to choose one later.
https://drive.google.com/file/d/15mN0B_RcB5KOxLbPlg-prFbBflA0ZqWc/view?usp=sharing

If more than 1 object is moving then the last section might need a for each object. I tested with just one object. As is, it would deactivate the behavior of both objects at the same time. A for each object would do 1 at a time. I don’t have the time to test it but I think that should work.

Add the for each object as a subevent and place the actions inside it.

cant you just do if a player object is in collision/touching another player object then you push it away?
image

zfoxx is using the pathfinder behavior. The seperate object action would push the objects away from each other but then the pathfinder would put the objects back on their paths.

I wonder if you could combine that with a pathfinder move action.

Objects collide.
Seperate objects
Refresh the path

You would still need a for each object and disable the obstacle behavior before and then enable afterwards.

I’ve said it once and ill say it again, use the boids behavior
it’s a replacement for pathfinding that pushes away the two objects when in collision with each other

well using the separate 2 objects pushes the first object from the second object like:
player walks into moving object, the moving object then retains movement from pathfinder behavior, but the player is stopped because they cant move into said wall object. so there for the player is pushed away from the wall, or another object you add.

Can you give more details?
When using behavior “BoidsMovement”, “Pathfinding” and “PathfindingObstacle” should be removed?

“Separate objects” is not quite suitable.
When using “Separate objects” players leak through each other or, if there is a large crowd, they can push each other into an area from which it is impossible to escape

1 Like

Yes, when using boids, you will need to delete the pathfinding and pathfinding obstacle behaviors. then just use the “intent to move forward” action in the events and the behavior will make them avoid each other automatically
image