I’m making a voxel (cube) game, and I have a tricky problem with the collision side of things. If you ever played most of the popular voxel games, like Minecraft, Cube World, Trove, etc. You will notice that if you walk into a corner (or up against a wall) and start turning, you don’t get pushed away from the wall (and the edges of the player sink into the blocks). If the player had a box shaped collider, the corners would cause the player to get pushed back as he’s turning.
But also, if you try to walk off a block, you fall off instantly, not sink away as if the bottom part of the player was that of a capsule collider.
Essentially what I’m saying is, the player collision feels like both a capsule and box collider at at the same time. And I’m having real trouble implementing that. I’ve gotten close, by making the main collider a capsule, and putting a box collider at the feet of the player. I have made the box collider less wide than the capsule, so that walls can collide with the capsule, while the blocks that the player is standing on top of, will collide with the box.
So far, after many iterations, it seems there’s no middle ground in the size for the box collider. As the player will either very slightly get pushed in a curve while falling off a block (due to the capsule collider), or push itself away from walls when turning (due to the box collider).
I tried freezing the rotation of a regular box collider (covering the whole player), but the collider would always update faster than it was being frozen, which caused very slight movements while turning. These movements were enough to be very noticeable.
I have tried searching, but this is so specific, that I just had no idea what to search. And searching things like “minecraft type player collision” definitely didn’t give any useful results (as expected).
Any ideas?
I found this video demonstration, which seems to do exactly what other voxel games do. The problem is, neither it nor the guide site it links in the description, talk about how this was done. It also wasn’t made in Unity.
P.S. The reason this thread is in Scripting, and not Physics, is because I’m 101% sure this will need to involve coding, and will not be possible otherwise.
P.P.S. I could just make a cylinder in Blender, and use it as a mesh collider, but the bottom of the player needs to act as a square shape.