I’m coding a pathfinding bot for a game I’m developing, and for some reason when one bot makes it through a waypoint, it sets the next waypoint as the next waypoint for all bots.
here’s the waypoint script: Race | Code Editor
and here’s the guidance script (I’m not sure if the issue is from here or not): Race | Code Editor
any help would be greatly appreciated!
Hi @Max_Finley-Mavragani!
Personally, I don’t see the value in using the WaypointManager script. I think it adds an extra layer of complexity that isn’t necessary.
Instead, I would handle waypoint management directly within the AI itself. When the AI reaches a waypoint, it can simply move to the next one in the array. This keeps the logic more contained and reduces the need for an additional script to manage something that the AI can easily handle on its own.
1 Like
I transferred the waypoint manager script into the AI, and it’s still causing this issue.
How do you test this, because I see only one AI car in your scene?
By the way, you can create the array more easily with the code below.
// initialize the array of waypoints
this.waypoints = this.app.root.findByName('Waypoints').children;
For this you need to create an entity with the name Waypoints
and add all waypoints to it (basically like you currently do with the AI array
entity).
This way you don’t have to add all entities manually to the attribute.
1 Like
sorry, I had deleted the second car for some reason. it’s back now
I solved the problem by adding the check below.

1 Like
it’s working now, thanks!