0 votes

I'm building a small indie 4x styled space game similar to stellaris (but in 2d). I've done galaxy generation. My current galaxy generates a ton of "stars" in a radius of 7000 x 7000. Each star is a Node2D, with a sprite and an area 2D with some code that tells the game how that star should behave.

A high-end game will have around 2000 stars... that are all basically pixel sprites. Should my game take a massive performance hit? And if so... is this unavoidable (e.g. 2000 star games should require you to have a better PC) or is there a better way to approach this? At the moment I don't notice much (FPS counter reads 165 fps flat with some slight dips but I'm not sure if that's just a weird coincidence)

I generate all the stars and their system on galaxy load, then plan just to store everything in a save so subsequent launches don't need to re-generate everything. They just place everything instead. While the galaxy is already loaded, no code is actually being executed besides some camera movement code.

With all that said, is it okay to just leave my galaxy generation and node structure as-is, or is there a possible better approach I should look into?

in Engine by (45 points)

1 Answer

+1 vote

In my experience with Civ and such, 4x games overall can be pretty taxing on lower-end PCs for sure, especially when the data begins to change for all your points through a game. Of course, sprite resolution can play into this and obviously, the smaller the size of resources, the less data churn.

What you’re working on is probably honestly out of the scope of my expertise, but it seems like you could just hide the objects that are off-screen so they don’t soak up data and free the queue when they are not visible. You could be sure to run a function that stores that data you need anytime, listens for visibility with a signal to itself, yield as it works, before it disappears, then re-instance it when it reappears?

Your game sounds awesome btw. Hope you succeed!

by (548 points)

I've thought about that but I think adding and removing nodes from the tree constantly might also get taxing. Was hoping maybe there'd be a more direct/simpler approach.

And thanks! It's been a really fun project to work on!

You can use "visible = false" and "set_process(false)". When dealing with higher number of entities it's better to process them by groups/chunks instead of one by one.

Would you use the viewport for this? So like ... check viewport boundaries and load in nodes based on where the viewport edges are?

This tutorial should prove helpful as well

GD Quest tutorial on Visibility Notifiers to save processing power

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.