[SOLVED] I need some pathfinders to treat a wall as an obstacle, others to ignore it

Hi.


In my game, players use pathfinding behavior. Each player is trying to reach their own goal. The pathfinders check, whether each of the players can reach their goal.

For example, player 1’s pathfinding must ignore the wall behind player 3. It cannot be considered an obstacle by the player 1 pathfinder (otherwise it can’t reach it’s goal). However, every other pathfinders (p2, p3, p4) absolutely must treat that wall as impassable.

The same goes for the other walls. Player 2’s pathfinding must ignore the wall behind player 4 and so on.

How do I achieve this? The official behavior that makes an object into a pathfinding obstacle is “universal”. It works as an obstacle for EVERY pathfinder. That won’t work for me.

Thanks!

1 Like

Before you move a player, you would need to disable the obstacle behavior on the wall(s) they can pass through. After the pathfinder move action reenable the obstacle behavior.

How you pick the wall(s) is up to you. You could use an object variable named player and check if the wall object variable equals the player object variable or you could use the animations if say the wall and player both used the same animations that represent the color. Red could pass thru red wall(s).

There are many different ways to pick the matching object. The main thing is to disable or enable the obstacles before the move action. Once a path is created, it doesn’t care about the obstacles. The object will follow the set path.

2 Likes

That worked really well. Thank you

1 Like