That Hole Game (Patreon)
Videos
-
610993697.mp4 -
hole.mp4 -
hole-truth.mp4 -
hole-fall.mp4
Downloads
Content
Recently, there was a really cool game that released about an all-eating growing hole.
So I thought I'd try to play around with that in Godot just for fun.
Turn out the mechanic is really simple... But there is some trickery involved.
The mechanic
The game uses a movable hole on the ground that lets objects fall into it and consumes them.
But how is this achieved? Using CSG or procedural meshes to change the hole is NOT the way.
There are two things that needs to be done. The visuals (creating the hole) And the physics. The moving hole collision shape.
If you remember an old game, Donut Country. It uses the same trickery as this.
The visuals
The visuals now with Godot 4.5 is really easy to do. Just use stencils.
Before it would require a custom shader with some sort of SDF to make the hole.
But now you just need to enable the custom stencil to write to 1 in a hidden hole mesh.And read not equal 1 for the ground mesh. Easy.
The collision trickery
Technically you can use CSG meshes with collision to carve a hole into the mesh each frame. But that is horrible for performance and can cause very unstable physics.
The proper way to do this trickery is to actually have a hole collision shape and an Area3D.
When an object approaches the hole and enters the Area3D, you just need to toggle its physics mask to collide with the hole shape, and not with the floor anymore.
And if it gets out... Toggle it back.
I got lazy there and just generated a multi-convex shape from a donut mesh. And then added a few box shapes around. But you should probably create a proper shape for the final game.
Because this is a RigidBody3D, for performance reasons, it is recommended that you use Convex shapes instead of Trimesh shapes, so I it is better to separate the collisions into multiple convex parts anyways.
Besides the hole shape, you also need a plane bordering the hole. So when the physics objects enter the hole zone and start colliding with it, they don't just fall into the ground.
But not all is perfect. Chances are you might still see your props falling when changing collisions.Keep your eyes on the Lemon.
This happens because the collision shape of the hole is slightly below the floor.
So when the physics resolves, there is a chance it ignores the collision due to being inside it.
The solution? Make sure the hole shape is just slightly above the floor.
You can even see when the object enters the hole zone and switch their physics on some released games that uses this mechanic due to objects jumping slightly up in position when the hole approaches.
Conclusion
A very interesting trick that leads to a very cool mechanic.
The video on the front is due to a bug where I forgot to reduce the spawn timer.
Which lead to that funny infinity spawning hole.
---
Also, some notes.
The hole needs to be a RigidBody3D. Just set the gravity scale to 0.
Trying to use a Character3D or a StaticBody3D will make things weird when moving it.It will either not wakeup the bodies when moving zones, or will push the bodies when moving.
The whole hole mechanic script in the end is super simple, and can be summed up in this very small snipped of code.
End
But that its.
Just a fun little project I made yesterday.
And about videos,
I recently did a makeover in the FPS demo scene so I plan to do several quick videos using it now. (not necessarily about FPS)
So hopefully you'll see a quick burst of videos soon. (which for me would be one a week)
And after that, I'll revisit the car video again.