DEV Community

Dustin Runnells
Dustin Runnells

Posted on • Edited on

Holes!

After several days of working on it in my spare time, I've finally gotten holes in my rooms to work! As described in my previous post, I need a way for the students in this game to walk or fall through openings in the walls. The glb objects that I created in Blender were great for unfolding and making texture images that will be easy to edit later to customize each room, but made it impossible for me to subtract another object from them to create an opening. I think that Godot does allow for a different (internal) shape type to subtract from, but I'm not doing it this way yet. This is what I have so far:

Image description

The final game will have multiple tools/abilities that can be applied to each student. The current state of things is that I can click on a sprite to position an invisible collision object that triggers the sprite to ignore floors. I was able to implement that as expected. The challenge turned out to be making it appear that there was a hole in the floor. This challenge consumed several days of me learning how shaders work. Godot has a separate language for dealing with shaders, and the concept itself is something that I've never needed to consider before. My custom shader is passed to the object through the material that I apply to each room. Two textures are in this material, one for the appearance, and another hidden texture that I only use to send the local coordinates of each "hole". From there the shader has a function to determine which pixels in each frame are within the radius of the hole and sets their alpha to 0 to make it transparent. It was a little work to get this to how I liked it because the coordinates of the hole is local to the room, which has different sized texture UV images and face rotations depending on the size of the room. In the end, it was interesting and educational and appears to have the effect that I want. I'll do something similar for doors opening/closing.

I think I'll work on doors next, and then maybe a simple test user interface to select the tool to use on the selected student. That should be a good foundation to add more tools/abilities and maybe create working level. I'll think about artwork later, but in the back of my mind I'm still thinking that I'll create a web based level editor that includes room making with uploaded wall texture/pattern images.

Top comments (0)