Godot Version
4.7
Both GDScript, and C++ with GDExtension.
Compatibility renderer enabled just for web export.
Question
I’m currently working on a Minecraft-y block game, one feature that’s important is blocks can be physical objects in the world so the player can build their own vehicles, I have most of the rendering and voxel managing figured out, but I don’t know how I should approach getting objects to interact.
My current method is generating a concave trimesh for my StaticBody3D chunk grids. (For chunk grids that are set up to be a RigidBody3D physics object I use simply a convex shape.) This is good because using the native physics engine works fine, and it means it’s easy to just use move_and_slide() in the player(the player is a cylinder CharacterBody3D).
However I am personally not a fan of this, I don’t like generating a new trimesh for every chunk, it’s slow and dumb, if an object falls though the hollow “skin” of the world it will fall forever instead of hitting a block inside, if a chunk is out of render distance entities won’t be able to touch it. I would prefer if I could have a custom solution instead that just samples the voxel data itself to act as if each block has an independent collider. Firmly decoupling rendering from physics, freeing up memory, and removing any need to preprocess collision.
The problem is, I have no clue how to implement this new physics body feature in the slightest.
- Can it be integrated into Godot itself with GDExtension, or should I custom build my own physics up from scratch?
- If I can use the existing physics, should I be using Godot Physics, Jolt, or Rapier?
- Do I need to handle every situation of collision between every type of collider (eg cylinders and convex shapes), or are there some shortcuts?
- What about scale and rotation?
- Can it work for mobile rigid bodies as well as static bodies for the ground??
Class tree for reference
# Level
# |
# L ChunkGenerator
# |
# L ChunkGrid
# | |
# | L ChunkRenderer (Cpp) <- this is where all mesh gen happens rn
# | |
# | L Dictionary[Vector3i,Chunk]
# | | |
# | | L PalettedVoxelGrid (Cpp)
# | | |
# | | L VoxelGrid (Cpp)
# | |
# | L ChunkLoader (static)
# | |
# | L (file system)
# |
# L LevelSaver (static)
# |
# L (file system)
TLDR: I need to create a new type of collider for my block game, how do I figure out the architecture?