Moth game: The sonar
|
I’m currently working on the reveal/sonar mechanic of Team Kraken’s latest moth game project. The idea is that you are a moth, and your primary means of sensing the environment is by feeling vibrations echoing off of objects around you. The vibrations come from flapping your wings, and if you flap hard enough in a certain direction (by pressing space) it will trigger the sonar. The sonar is a cone of vision stretching out in front of you. Right now this is all represented visually as shown in the image below:
I implemented the reveal effect using a shader. The shader takes a vision mask texture as input and applies it to anything currently on the screen, keeping it where the mask is white, and fading out to black where the mask does the same. It does this by multiplying the colors of the pixels on screen with the colors of those in the mask. To make the mask dynamic, so it could be white around the player and where the sonar is used, I first made it into a render texture. That way, I could let a special vision camera draw into it. The vision camera’s background is set to black, and it can only see objects that are in the vision layer. The vision layer objects are white sprites with fading edges; the stationary reveal field attached to the player object, and the sonar cone. The whole process of getting the final image on screen is thus as follows:
The problem with how it’s currently being done is that unless the player is using the sonar, everything on the screen except the tiny area around the player is entirely black. This makes the game seem quite dull and void of color and artistic expression during those moments. We have discussed a few different ways to deal with this, including:
|
