+3 votes

Hi

CONTEXT:
I'm new to Godot and Game development in general.
I'm trying to build voxel-/block-based, editable terrain (for simplicity sake, think of it like minecraft). I want the player to be able to view far into the terrain.

I first tried creating the terrain with every block being a StaticBody (with MethInstance and CollisionShape). Starting at around 20.000 blocks the performance went down dramatically.

Now I'm using MultiMesh instancing and the performance for drawing the blocks is incredible. But I don't know how to add collision shapes / collision detection to the MultiMesh instances (so in this case my player character falls through the terrain).

My current solution is to create separate StaticBodys that hold all the collision objects (in this case BoxShape) for the meshes. Keeping track of the collision shape and the mesh separately seems tedious to me, especially when editing the terrain.
Also I have been hitting some performance issues when creating a lot of collision objects (basically the same issue as my first attempt).

Things I already thought of:
- I could only instantiate collision object close to the player (within the radius of interaction, e.g. gun shot range), but again, this seems tedious.
- I could combine collision objects, thus reducing the amount of collision objects, but again, this seems tedious.

ACTUAL QUESTION:
Is there a more efficient / scalable / performant way to assign collision shapes to MultiMesh instances ?

Any help would be greatly appreciated :)

in Engine by (72 points)

1 Answer

0 votes

I've had the same question for Octron Mania, and I dug a bit.

Short answer : make one static body, add many shapes to it.

There may be some more perfs to gain by crafting one complex shape ; not sure.

See https://godotengine.org/qa/52924/solved-how-set-collisionshape-on-multimeshinstance

by (18 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.