But my issue now is the collision system. Currently, it works perfectly for the main chunk at [0, 0, 0], but all the other chunks have very inconsistent collision meshes. If I walk around, I am fine, up until I go to another chunk, where I just fall through the floor. My code is no different, and yet it acts different.
I guess the problem is more complicated than I thought… how can this be? There seems to be a condition that I am not aware of. If you do not know, feel free to pull in anybody else who may know about abstract things like procedural generation.
Well, it is hard to say without some debugging. The current code is hard to debug, and I mean, I can’t open it, glance through and say - hey the problem is there. You’d need to spend time studying the math that is used in the code.
What I would recommend is make your voxel world 2x2x2, making it basically an 8 voxels only. Once there, make sure you can remove a voxel from each corner of the world. Once done, double the size of your world and make sure you can still remove the voxels from your corners. Once done, make sure you can remove/add any arbitrary voxel from/to world. Once done, you can expand your world to larger scales.
Ammo Debug Drawer that Leonidas suggested is helpful for debugging this. I have in my todo list to update it to allow people to adjust the lines draw distance, so it doesn’t clutter the screen with far away meshes.
I took your advise and started smaller. Luckily, I found the issue. It is not that the collisions are not there, but that they are separated from the mesh somehow. I think that the x16 scalar to space out the chunks are somehow affecting the collisions separately from the meshes. But, setting the graph nodes Local Position to zeros do nothing.
Yeah, you may have to make your own player controller. Since I am using my phone for all of this, I made a primitive touch controller to look around and navigate. You may be seeing the first chunk, which DOES have the collisions in the right place. It is really the others branching off from the corner that are being problematic.
If the collisions all work on your end, I may have to transfer my code to a new project…
Thank you @Leonidas and @LeXXik! I took your advice and solved the problem, albeit relatively inefficient.
I experimented small, and found the issue. For whatever reason, the GraphNode transformations of the visual mesh and the collision mesh were acting different. But, when I tried to give them separate variables, it still would not work. Either the collision mesh was fixing itself and the visual mesh acting up, or vice versa.
So, my solution was to create a sub-entity parented under the chunk entity, assigning its collision model from the chunk entity, and transforming the node via the sub-entity.
Even though it is essentially doing the same thing I tried from the beginning, the engine is treating it differently. But it works!