Support Forum

Path isn't being calculated correctly, coming out at 0

Hi again,


The AI I have currently does a check for the players position, they always know the position, so in my code below I have the code that gets the current position of the persons turn, then the target they are checking the distance between. But for some reason when I have the traversal modifier on the player, which is written the same as you have on your Demo AI.

    public void TraversalProviderSetup()
        // 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<SingleNodeBlocker>() { blocker });

it doesn’t move at all, says that the costOfPath is equal to 0. I’m not sure why the code is doing this. Each unit has a single node blocker and all have the TraversalProviderSetup. But for some reason the Constructed path between the 2 is saying it’s equal to 0. This is what the grid looks like, as you can see, there isn’t anything blocking the players
Was wondering if you’d know why this is happening. It only happens when the line of code

path.traversalProvider = CurrentUnitTurn.traversalProvider;

is enabled. Also when I use the blocker.BlockAtCurrentPosition function, it’s not actually blocking the player. Or if it is it blocks itself for some reason.

I’m under the assumption because I’m blocking the node at the feet of my player, the aI don’t know how to make a path to a node that is blocked and is thus coming up as an error path. Is there anyway to figure this one out?

**Edit, I made it so only the enemies block their positions. As I can manually click them. The player however isn’t a solid object now and all of a sudden the AI appears to be heading towards the player whilst avoiding eachother. So it was a fact the grid couldn’t reach the destination.