The Settler like prototyping, performance and Unit-Management, newbee to game development
-
Hi,
i began working with godot at the beginning of october, and since created a foundation for a 2D startegy game. I am sharing the work here so you and me can profit from it.
I made a "Task queue" for my units which can take them by their type of unit, eg. worker should build the buildings, warriors should go to fight (currently they just go to the end of a new road) etc. I have a unit manager, which does manage this queue as well the idle units. While having this functionality i can do on my laptop 1500 Units with 60fps (i5 9th generation, gtx 1660ti) which is i think quite decent but far from perfect as you see down below.
There is a UI just for testing, and that is actually the part where i am most confused. If u have a good ressource for structuring ui functionality in an efficent way i would be really happy.
I have roads, different buildings and different units, which will now be refined and made actual gameplay from. The Tileset is a simplistic one from the www, which i actually enjoy working with. I the longterm i would switch to custom made grafic but this is definitly down the line.Here a video of the basic functionality i implemented:
I stresstested my game and yea...:)
It still did 16 fps, just to be clear it were really ~4300 Units(the@number) on the map, moving and getting tasks to random positions on the road network.If you have any idea how to optimise the movement of units, i am currently using move and slide with an array of vectors as path. I am not really sure yet if i really want this, but is there a possibility to make the movement retro style, like generating a path which the unit can follow.
-
Well since you are using tiles you could get rid of using collision and just not allow units to move out of bounds, but even then the sheer amount of nodes can cause a performance decrease, so the best way could be to unload units and calculate their time of arival in the backround, or if you dont want to make something too conplicated like that, you could make it so that the process steps are less on unloaded nodes, so instead of moving them every frame move them on a tick like 10 times per second.
-
@Salodo Actually I use the AStarGrid2D for the pathfinding and no collision, the collision just turns on for a splitsecond when the unit reached its target to get the building its on, or later trees etc.
I was wondering if I switch at some point to the AStar2D and create the points of the street dynamically. Its just unconvinient to work with that and tilmaps together. Currently i just switch the roadtile from solid to not solid and thats it. Unloading or lowering the tickrate sounds great at some point ill look into it how to do it, but especially unloading could really play into the custom AStar2D. -