Greetings and Happy Monday from Travis!
This whole semester I’ve been working on tweaking and developing the look and feel to the fire spirits, which are mysterious, mystical beings that Fella uses throughout the game to solve puzzles. It has been a long process of programming, testing, and debugging, but they’re finally reaching a point in-game where they’re fully functional.
When I started, the first thing I needed to know was how these fire spirits were going to work in the game and how Fella will be interacting with them.
The mechanics and behavior of the fire spirits consist of several stages. Fire spirits have two primary states: extinguished, when they cannot move by their own power, and ignited, where they hover in the air and can be used to activate switches. They hate rain, and any contact with rain or water extinguishes them automatically. Fella can interact with extinguished fire spirits by picking them up and carrying them over to a bonfire, where she can throw them in to reignite them. Once they’re ignited, Fella can protect the fire spirits with her umbrella and lead them to covered sconces (or torches) on the wall, and doors unlock when each fire spirit is lit and placed in a sconce. The opened doors lead to the next area in the level.
I started off the programming by setting up the different possible states that the fire spirits could be in: extinguished, picked up, on fire, and in the sconce.
I next wanted the fire spirits to start following Fella once they were ignited. At first, I tried to do a NavMesh, which is an easy way to tell an AI how to move. But this produced some errors (especially when Fella jumped), so I eventually decided that it would be better to just have the locations of the fire spirits based on Fella herself, and I worked on that during our first development sprint.
Most of the second sprint was spent creating a simple AI that controls how the fire spirits change between all of the states they can occupy. The first step was to make sure that the script knows what to do with each fire spirit depending on what state it’s in. For example, the script has to know that extinguished fire spirits fall to the ground and cannot move on their own, and ignited fire spirits rise up to float around Fella and follow her around (kind of like ducklings).
Once the script had all of these states and their behaviors sorted out, I had to make sure the AI could handle multiple fire spirits at once. Fella can have up to four fire spirits following her at one time, so I ended up creating an array (list) of game objects that can hold up to four fire spirit objects. The script can then update itself and manage all of the fire spirits at once depending on what Fella does with them. For example, since only one fire spirit can occupy a sconce at a time, if Fella wants to place a fire spirit in an empty sconce, the script makes it so only one of the fire spirits will move to the sconce, instead of all of them fighting for position.
After I finished programming the state changes, I decided to revisit the way the fire spirits moved. I wanted to make them feel less rigid, so I added a very slight floating animation that makes them bob up and down along a cosine function (a curve). This makes them look a lot more like they’re actually hovering in the environment. I also smoothed out their motion to and from the sconces through Lerping, which is short for ‘Linear Interpolation.’ Lerping allows me to blend between two points and create a smooth animation from one place to another. My next task was to have the fire spirits slowly orbit around Fella when they’re following her. This was tricky, because the fire spirits had to move independently of Fella’s rotation (basically, if Fella turned right, I didn’t want all of the fire spirits to turn right as well). I ended up setting up an invisible object that follows Fella while slowly rotating at the same time. Then I parented the fire spirits to this new object instead of to Fella herself, and I made sure they could figure out where they should be, using the same interaction script from earlier.
Throughout our development, we’ve come up with new ways to use the fire spirits as puzzle elements, and we added a new state midway through that I hadn’t accounted for in the beginning. There are some new fire spirits who have an additional idle state, where they’re already ignited but they’re not following Fella yet. This state isn’t all that different from the states I’d done before–the only difference is how they’re added to the array. I set up a trigger function that detects whether Fella has walked near an idle fire spirit, and if she’s close enough, it automatically drifts towards her and begins to follow her, just like the others.
Most recently, I’ve been working on getting the fire spirit to extinguish automatically after being exposed to rain. To start, I had to give each fire spirit a countdown that tracks how long it’s been in the rain (it’d be frustrating to players if it extinguished right away). If Fella doesn’t cover the fire spirit with her umbrella in time and the counter reaches zero, the fire spirit will drop to the ground, and Fella will have to reignite it before she can place it in a sconce.
In order for this to work, the fire spirit has to know if it’s in the rain, how long it’s been in the rain, and whether or not Fella’s umbrella is over it. Because it’s possible for a fire spirit to drop out of the array of fire spirits following Fella, I had to rethink and redo the logic that keeps track of the total number of fire spirits following Fella. To make sure I had all cases accounted for, I created a function that checks all of the slots in the array to see which ones actually contain fire spirits and updates accordingly. If there are any open slots in the array, the script knows that Fella can pick up another fire spirit to fill that slot.
We have a fire spirit drawn on one of our whiteboards, and each week I like to have it say something based on the progress I’ve been making. Here are some of them:
It’s been a long process, but we’re excited to have the fire spirits ready to go for our playtest this Friday!
Our first public playtest is this Friday, December 8, from 11am-1pm in the MSC Brew Devil’s Nook! Hope to see you there!