Valks-Games / TopDownGame

MIT License
2 stars 1 forks source link

FPS drop spike on starting game #13

Open valkyrienyanko opened 1 year ago

valkyrienyanko commented 1 year ago

This happened with the new pathfinding code

JamesDepret commented 1 year ago

If it's a temporary drop then it's probably because it's connecting all the points on the map, I'm not sure if this can be handled asynchronously (by that I mean if Godot can run it async).

Because it needs to use "world" for its start and endpoint it needs to be run after the world has been initialized. So that's currently when the game is up and running, it'll run init... There might be a better lifecycle hook to run this on after all the _Ready functions have been run, but I'm not sure if such a hook exists.

In the init of AStarPathing ResetPaths() sets the start and endpoint to the left-top corner of world and the right-bottom corner of world. The follow-up method then connects all points, which is 8 calculations times the total amount of coordinates. (8 = each direction)

To test if this is the issue, we could manually set these startpoint and endpoint values in the ResetPaths() to something more acceptable. Again only positive numbers should be in the coordinates.