Skip to main content

UFOlogy



As a fan of the show Project Blue Book, I was keen to implement the UFO unit for the alien toys in Batteries Included.

The role of the UFO is to harass the player's goons. It does this by abducting individual goblins via a tractor beam. The player can stop this by grabbing the UFO (and tossing it away like the bad toy it is).

However, the UFO will return to continue abducting goons if the player fails to keep track of it.

Another mechanic of the UFO is the ability to escape: if the player has held on to the UFO for several seconds, it can escape out of the player's hand, becoming holographic (which temporarily makes the UFO intangible). This triggers a haptic vibration in the player's hand holding the UFO, and the UFO takes on a hologram shader. The purpose of the escape ability is to prevent the player from simply holding on to the UFO indefinitely; the UFO has a mind of its own, after all!

There are two qualities of the UFO's programmatic design that I would like to discuss: the modularity, and the interpolations.

The modularity of the UFO was a design decision allowing each aspect of the UFO to be controlled individually, without respect to the other modules. Here you can see all of the scripts involved in a UFO prefab:


Communication between modules is handled via events – only when one module is triggered by an event it is listening for (from another module) does that module react. There is one exception, and that is for what is controlled by the UFO's behavior module; this module runs the acting logic of the UFO based on the statuses of its various components. The conditions upon each other module are all driven via events, however. This means you can remove one module and the rest will still function. The other benefit to this approach is arguably even more useful: programming for distinct functionalities allows for a simplicity of mind. One does not have to consider every logical possibility when working inside one mega-script.

It doesn't happen very often at all in development that things work right the first time you hit play. But the UFO was an exception. I was amazed to see UFO fly over to the nearest goblin, extend its tractor beam, and float the goblin up to its bay until, with a poof of particles, the goblin was gone. This creation was special to my programming experience because it reinforced the value of modular programming for being efficient, easier to think about, and less error-prone.

The other quality of the UFO is the use of interpolations in its actions. For these cases, I utilized the Interpolation Curved script included in my Moon Motion Toolkit. Using the functions in that class allowed me to easily interpolate values for the UFO according to a "smootherstep" curve. This interpolation was applied to the floating up of goons being abducted, as well as to the flight velocity of the UFO chasing a targeted goon.



These interpolations make the spectacle of the flying and abducting UFO more visually pleasing. It also makes a key difference between a programmer-prototype and a polished game mechanic.

Creating the UFO for Batteries Included was the most satisfying and rewarding development experience over the course of the project. It was well-received in playtesting, where players explained they enjoyed watching it abduct their units but also being able to throw it across the room to exact punishment.

Be sure to incorporate these development aspects into your next design, if you haven't already! I can vouch for the positive effects of modular coding and using smooth interpolations in games.

Comments