I have around 100 enemies on screen, and I feel that using “Pathfinding” causes a lot of lag in the game. Is there a more efficient way or an alternative system that allows enemies to find the player through obstacles without directly relying on “Pathfinding”?
If you’re updating the paths on every frame then you could try using object timers to update them less frequently. You could pair it with distance checks so it updates more frequently when the enemies are closer to the player. Maybe, you could also figure in the player’s speed.
Excuse my ignorance, but can you explain it better? Maybe with an example or in more detail.
Add to one object a object timer
Start it at beginning of scene
NOW
Condition
Timer of OBJECT is greater than 1
Action
Remove forces from OBJECT
Add PERMANENT force to object toward angle Random(360) speed of 20
Reset OBJECT timer
Test if that works and if it will well it WILL
Now you need to do the same for setting path
But instead of adding/stopping force you just set new path for your object
For example you give your object 2 variables TargetX TargetY
And second you set new path instead of setting new path each frame
So you set TargetX TargetY to Player.CenterX() Player.CenterY() and now you move your object toward these variables after you set path to it
You could also do add force towards object…
