"Blocking Nodes" pathfinding with other components

I’m trying to use the code found in the “Blocking Nodes” section (found here https://arongranberg.com/astar/docs/turnbased.html) to cause nodes to be blocked based on other variables. The entities this will be attached to is already using AIPath, a modified AIDestinationSetter and the seeker components. if i want this to work as intended, do i need to remove one or more of the components, or edit one of the existing components to include the necessary parts?

Hi

That section is mostly intended for turn based games. However you can use it with AIPath too. You need to call the SingleNodeBlocker component’s functions when you want to block a node for the other agents.

I wanted to use the node blocker to allow the player to be viewed as an obstacle when a variable is true, because the enemies got stuck on the player when moving to certain points. I’m just not sure if I need to edit any existing component scripts, or if I just add the new script from the blocking nodes section and maybe disable another component.

Hi

I don’t know anything about your game (is it even turn-based?) so it’s hard to say what you should do.
However the AIPath script does not use the ITraversalProvider automatically. It is intended for custom movement scripts. You might be able to override the SearchPath method of the AIPath script to use an ITraversalProvider however.

Should’ve go into some detail so that’s my fault.
I’ll go into the full rundown of my issue and the situation.

  • The game is 2d, and not turn based

  • The issue I’m having is that when the enemies need to move to a specific point, they can get stuck on the player (I can update with a video of the issue in a bit)

  • I was trying to see if there was a way to set the player as an obstacle, and therefore to make the path avoid it, and was directed to the blocking nodes section, so I figured that was what I was looking for as I figured they were likely to be more knowledgeable about it than me.

If there is a better way to solve this issue I would be grateful to know.

Many Thanks.

Hi

Sorry for the late answer.
The two types of avoidance included in this package are the ITraveralProvider and local avoidance (see https://arongranberg.com/astar/docs/local-avoidance.php).
The problem with just setting the player as an obstacle is that the player can often move pretty quickly and therefore even if you block the agent’s paths they will become quickly become invalid because the player moved.