What I’m trying to do
I want to make a top-down shooter that pits one player against one enemy. This enemy will travel by pathfinding to nodes. The purpose of this node system is to:
Have better pathfinding than the default GDevelop pathfind behavior by itself.
Allow for special actions related to nodes. Such as “If player is at X and unarmed, move to X. If player is at X and armed, move to Y and take cover.”
What I have so far
I have built a node system made of numbers. It is functional and works by pathfinding the enemy to a number. For example, if the enemy needs to move to 1 and is at node 5, he heads to node 4. Then from 4, he moves to 3. And so on.
This is how my node system functions. If the enemy needs to go to node 1 like in the event example above, every other node in existence has a response. If the enemy is touching node 40, I will have made a set path on how he can get from 40 to 1. Every path will take every other node into consideration.
“The boolean value of scene variable Moving” tells the enemy to move.
“GoHereEnemy is in collision with _1” tells the enemy what path will be considered. In this case, move to node 1 (by moving to related nodes).
“RifleEnemy distance to X is below 50 pixels” tells the enemy which node he is at right now.
These three are combined to determine which node should be moved to next. If the enemy is told that the path is for 1 but he is touching node 9, then he moves to node 7. Then he moves to node 5. Then 3, 2, and finally 1.
The issue I am having
The issue is a workload/efficiency one.
If I have 40 nodes, each node will take 39 events. This way the enemy can always reach every node from anywhere.
40 multiplied by 39 is 1,560. That is 1,560 events to the basic act of pathfinding for a small map.
I estimate that most of my maps need to be even larger than merely 40 nodes.
What should I do in order to cut down on the amount of events I’ll need to make node pathfinding? Please explain the solution to me in layman’s terms as I am pretty new to GDevelop… especially if mathematics are required.