[SOLVED] Can't get pathfinding to work with array scene variables

I’ve made a test game to get my structure right. I have a pathfinding character who goes from destination to destination for varying lengths of time. At the moment the character is just going to text labels for made up activities.

It was all working fine. I had just had the array scene variable only. But then I wanted to remove each destination as it was reached (and put it back later - never got to that). And when I tried removing a variable, it didn’t work. So I found some stuff in the forums about it and changed to having an array variable plus a double variable system of index and value similar to this method mentioned in this post.

But now nothing happens, the character just goes to the default destination 0, as seen in the Activities Group. And the index value variable stuff never happens. I feel like everything is reasonably right, but something is in the wrong place? I’ve tried different combinations but after going to destination zero, the character doesn’t go to the next place. I have changed the names of the scene variables but think I’ve updated them all in the events.

Here are my scene variables and event sheet. I checked that the variables were numbers.

The values in your array are strings, yet, you are using them as numbers in your events.

1 Like

Thank you, changing the array values to numbers helped. But I still have a problem. After changing them to numbers, the pathfinding still didn’t work until I removed Trigger once from the Timer condition. But if I remove that, while the pathfinding works, the timer stops working after the second destination and the character goes from place to place instantly. I tried different combinations of places to put Trigger once, but nothing helped.

Do you reset the Counter timer anywhere? I would have thought you’d do that in the event that checks the Counter timer. Then you won’t have to worry about the Trigger Once.

Good catch, thank you. I’m only meant to have one timer but changed its name in one place and got distracted and forgot to change it in the other places.
The timer gets started at the beginning of the scene and reset in the timer event. So now that I’ve fixed my naming mistake, the pathfinding works but the timer doesn’t work at all even from the beginning whether I have trigger once there or not. After doing the renaming I closed the project and opened it again and restarted GD, but still no go.

This is the current version.

Your player reached destination isn’t nested under the Activity timer check. Should it be? And are you trying to move the Player through the various points but in a random order? If so, are point visits allowed to be repeated?

Another stupid mistake from me, yes in my first screenshot, the destination condition is correctly nested. After trying so many variations to get things to work, I mucked up putting it all back together again. Thank you MrMen, both pathfinding and the timer are now working.

And I moved the toggled off remove variable at index action into the destination condition and it’s almost working properly. The player goes to all destinations but goes to one of them twice. I tested this a few times, taking notes. And then at the end it goes back to destination 0 which I can live with. I can live with the other thing as well, but don’t understand why it’s happening.

Yes, my plan is that there will be player behaviors and things going on at each destination. The order will be random and also the length of time at each one will be random. I know there’s an extension called Array Tools and I tried that but it didn’t seem to suit it. Well not when I incorrectly had named arrays anyway. But I saw some good ideas in the Array tools so what I’m thinking is that I’ll toss those removed visited destinations in to another array. And then when a percentage of destinations has been reached, say one third, I’ll merge both arrays so that there’s a full choice again.

It’ll be because at the beginning of the scene you pick a random List entry, but don’t remove it (like you do when player reached destination). Remove it in the “Beginning of scene” event, and all should be tickety-boo.

1 Like

Ohhhhhh, so clever, thank you again, it is indeed now tickety-boo, ducky, even. :duck: