0 votes

Hello,
I have an issue related to this topic:
https://godotengine.org/qa/27821/how-to-improve-gridmap-performance-octant-size?show=27952#c27952

In short, if I use a 3D GridMap with a meshlibrary composed of Meshes ONLY, the loading of the map is superquick (i´m talking about hundreds of thousands of mesh - if not millions- in a few seconds).
If I go with a meshlibrary composed of StaticBodies (i need them to detect the click of the mouse on the object placed on the gridmap), a simple 10 thousands bodies map will takes several minutes to load, a 50k bodies map will take up to 15-20 minutes.

Point is I was expecting a slow down of the performance, but one would expect adding physics objects would impact mainly on the frame rate, but that´s totally untrue: the framerate remain basically untouched.

I would like to know where this slow loading time came from, why does a static body take more time to appear on the scene than a simple mesh, even before any physic is involved?

Andrea

in Engine by (1,455 points)

i just saw an email saying you replied my post and gave me hopes that you found a solution, just to came here and read this XD

So you didn't actually read it? When I get my email from this website it shows me what comments I get too.

nah, i click the link, then read

I just had a similar problem instancing nodes with static bodies. Not sure if it applies to your case, but in mine, changing the position of the node before adding it as a child solved the problem.

var child = Child.instance()
child.set_position(Vector2(x, y))
parent.add_child(child)

I guess Godot recalculates collisions on each child added and, by default, they would stack on 0, 0, causing the lag.

This works, thank you!

 # Create many collision shapes
var collisionNode = StaticBody.new()
collisionNode.set_translation(Vector3(i * 10, 1, 1))
self.add_child(collisionNode)

1 Answer

+1 vote

Just came across this question as I was having the same issue and wanted to add to it.

I initially fixed the issue in a different way: I set the collision layer and mask and the for the static body to different layers so each tile wouldnt interact.

This worked, and it may be worth doing this also. But cgx's answer is very efficient.

by (16 points)

If only I had those answers 2 years ago :)

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.