0 votes

So, I'm making a hex based map editor.

At the moment every hex is a separate node. It's working but gets sluggish if I have something like 100X100 grid.

What can I do to fix the situation?

in Engine by (21 points)

2 Answers

0 votes
Best answer

10000 nodes are a lot but not enough to make the tree slow by themselves, first try to find more information about your problem, use the monitor and profiler to get a better guess of where is the issue (it could be in process, events or something else).

In any case you may need to optimize your design with a system of chunks/zones/cells with groups of nodes that are enabled or disabled (in or out of the tree) with certain conditions, but what to disable will depend on what are those nodes doing and where is the bottleneck.

by (7,860 points)
selected by

I ran the profiler and got this: FrameTime 0.26721, IdleTime 0.26244, none of the functions takes more than 0.00040 and there is not many of them. Monitor does not show anything weird. There is a performance spike when I generate the map, but that to be expected. I have no idea what to do next.

Maybe try adding a VisibilityEnabler2D node as a child of the Camera2D? The renderer should cull nodes located outside the camera view automatically, so I'm not sure if this will help.

0 votes

Figured out what was wrong. The problem, as eons has pointed out, had nothing to do with the nodes. I have a _draw() function for drawing hex grid. And, well, I was drawing all 10 000 hexes every frame, one line at a time.

by (21 points)
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 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 webmaster@godotengine.org with your username.