Pathfinding doesn't appear to work with negative integers

Wondering if this is just the nature of the script and it’s not showing up in Gary’s video lesson bc his starting point is at 0,0 and the enemies are only heading into positive directions - but my current layout has a negative coordinate for the starting location -2,1 and when I try to run the game the console gives me an error that the given key (-2,1) was not present in the dictionary. I’m wondering if this is just the nature of the script. My enemy pathfinding and movement work completely fine if I make the starting point a positive integer. It’s not the end of the world to rebuild my grid so gameplay only happens on positive integers, but I’m just curious if this is the script working as designed or if I’ve made a mistake somewhere.

Hi MidgeBrew,

Welcome to our community! :slight_smile:

You are right. Negative values do not work. The reason is not the pathfinding algorithm itself but the imaginary grid which we create with two for-loops. See the CreateGrid method.

Did this clear it up for you?


See also:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms