SingleNodeBlocker Issues


I’d love help trouble shooting for getting my SingleNodeBlocker to work (same from TBS example). I feel like I have everything required yet it is still not blocking other single node blockers in the scene.

I’ve changed a few lines of code and tested them in the TBS Example that was given to us. I just made it so the TurnBasedAI and SingleNodeBlocker scripts set the BlockManager automatically-- since I can’t set the BlockManager manually due to instantiating objects. They still work in the TBS example-- so I am assuming this is not an issue. I’ve copied the changes below (new lines in bold).

I have a TurnBasedManager GameObject with a TurnBasedManager (this is a copy of the original TBM script with a new name) and BlockManager script, my Units have a TurnBasedAI and SingleNodeBlocker, and my obstacles have a SingleNodeBlocker as well. Any help would be greatly appreciated! I can try to give additional information if needed as well.

TurnBasedAI Change:

protected override void Awake () {
blockManager = FindObjectOfType();
// Set the traversal provider to block all nodes that are blocked by a SingleNodeBlocker
// except the SingleNodeBlocker owned by this AI (we don’t want to be blocked by ourself)
traversalProvider = new BlockManager.TraversalProvider(blockManager,
BlockManager.BlockMode.AllExceptSelector, new List() { blocker });

SingleNodeBlocker Change:

public void BlockAtCurrentPosition () {
manager = FindObjectOfType();


It’s hard to say. What have you debugged so far?


Thanks for the response! The game is a 2D TBS.

Testing in your TBS example has shown that you can set everything with no problems in a script with FindObjectofType<>(); so that doesn’t seem like an issue as everything still works in the example.

In my game, each player has a rigidbody2D, the TBAi script, and a single node blocker. I have a TBMovementManager in the scene with a TBManager (new, but I tested renaming a copied script in the example and it still worked) and a BlockManager. Also, I have objects in the scene that have a single node blocker script on them.

So, it seems like I have everything correctly set up for it all to work. When an unit starts the movement script it sets path.traversalProvider = unit.traversalProvider like in the TBS example.

Do you know of anything that might interfere/override a single node blocker? I’ve attached an image of what is on the character, the TBSManager, and the A* object.