UPDATE:
I got them to move, but I'm now running into an issue where the last dots to move down move a cell too far and intersect with other dots.
Here's the capx:
______________________________________________________________________________________________________________________________________________________________
Hey everyone. I'm new to construct 2 and I'm trying to work out an issue with path finding.
Right now I have a hex grid filled with "Cell" objects, each with an instance variable "Index" that's a number between 1 and 36 (It's a 6x6 grid).
The dimension of the grid is denoted by "DIMENSION" global variable (in this case, 6)
Cells also have an "IsEmpty" Boolean variable.
Initially the grid is filled with "Dot" objects. Throughout the game the Dots are destroyed, emptying their inhabited cell (Setting IsEmpty to true).
The distance between each dot on the grid is denoted by a variable "DistBetweenDots"
To handle this I have the following event block:
The nearest dot is selected, and we compare its distance to the current cell.
If there is no dot in the current cell, the distance to the nearest dot will be greater than DistBetweenDots/2.
Then, for all empty cells (excluding cells in the top row where Index > DIMENSION, because in that case new dots will be spawned)
I want to move a Dot from above into the empty cell. The dot to be moved is in the cell whose cell index is (empty cell's index - DIMENSION)
For this, I create a function MoveDot, with parameters (Dot's current cell index, target cell x, target cell y):
As seen above, I have placed debug statements to see where it goes wrong.
I am able to get to the point where a path is found. But once I call On pathfinding path found:
It does not execute. I know this because debug2 does not get set to "setting along path"
The logic seems correct. I'm not sure why the On "Pathfinding path found" Event is not triggering. Is the dot unable to find a path? Why would that be?
Here's the capx:
Thanks for any advice.