0 votes

Hi,

I'm creating a voxel-based game with procedurally generates rooms. I've created a 'voxel-no-collision' scene which just contains a single MeshInstance node, and elsewhere a 'room generator' script instances this scene and then uses a SurfaceTool to build the appropriate cube faces. Without any collision involved everything runs at a reasonable speed. However, when I have the room generator instance a different 'voxel' scene which is identical except it also contains a StaticBody and CollisionShape (which has a default BoxShape and a scale of 0.5, 0.5, 0.5) the level generation becomes very very slow.

As a point of reference, I instantiated a 20x20x20 grid of cubes without collision and it takes on average about 125ms to complete, but with collision it takes on average 5 seconds (i.e. with collision it is 4,000% slower!)

For comparison, I set up the same process in Unity (spawning a 20x20x20 grid of Cube Prefabs - both with and without a BoxCollider). Without collision involved the instancing speed was very similar to Godot (around 125ms), however the addition of a BoxCollider to the prefab had a far smaller impact. The total time to instance all 8,000 'cubes with collision' increased to just 200ms - so only 60% slower which is a lot better that the 4,000% slow-down that I'm seeing in Godot.

Could anyone please explain the cause of the delay that I'm seeing, and let me know if there is a different approach that I could take in Godot to achieve similar speeds?

Thanks in advance.

in Engine by (53 points)
retagged by

1 Answer

+2 votes
Best answer

This is a known issue since the migration to Bullet, see this GitHub issue. Try switching to Godot physics in the Project Settings and see if performance improves.

by (9,694 points)
selected by

Thanks! It's about 5 times faster with Godot Physics, but I get other errors and my character no longer moves. But I made a few optimisations in terms of how many colliders I need and I can probably design around other performance issues for now, so I'll stick with Bullet.

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.