*title pun courtesy of my brother, Richard Edwards

Over the last couple of weeks, I have been getting back into working on my game, and instead of trying to battle with the inventory system again, I thought I’d try working on something that I could make some more immediate progress with: the interactivities for another destination. One of the key concepts that I want to get across is that while the mantle (the very thick layer that makes up 84% of Earth’s volume and acts as the main medium for plate tectonic motion) does move and flow over large timescales, it is mainly solid and it is actually quite difficult to melt to form the magma that fuels Earth’s volcanoes. In fact, there are only three ways you can cause melting (and they don’t happen all that often): 

  • Increase the temperature: this is the most intuitive, but not the most common. Most of the Earth’s interior isn’t hot enough to melt the rocks present in the mantle, given the high pressures, so you need unusually high temperatures, found in what are called hotspots, or large upwellings of hot material that slowly punch up through the depths of the Earth like a lava lamp. It is a hotspot like this that cause the volcanoes in Hawaii
The caldera and lava lake of Kilauea – Hawaii’s most active volcano (photo attribution: Brian Snelson, https://www.flickr.com/photos/exfordy/5234991534
  • Decrease the pressure: this is somewhat less intuitive, but thermodynamically sound (put simply, solids – except for weird substances like water – are typically denser than their liquid counterparts and therefore are stable when under higher pressures. Consequently, if you reduce that pressure, the liquid becomes more stable and melting ensues. This decompression melting is responsible for a large proportion of the magma found globally, including the extensive oceanic mountain ranges found in the centre of our oceans where two plates are moving away from each other and causing low pressures. This is where we find the so-called mid-ocean ridges, such as the Mid-Atlantic Ridge.
A “black smoker” – superheated gas venting out of mid-ocean ridge features on the ocean floor (photo attribution: MARUM – Center for Marine Environmental Sciences, distributed via imaggeo.egu.eu,)
  • Add some fluid (especially water): finally – and least intuitively of all – you can cause the mantle to melt by adding water. In these situations, the water acts in the same way as salt added to icy roads – it lowers the melting temperature sufficiently to turn solid into the liquid. The resulting magmas are very high in dissolved water (like the water on the roads is very salty), making them highly explosive. This type of melting – caused by water released from tectonic plates as they descend into the depths of the earth at subduction zone plate boundaries – is associated with the highly explosive volcanoes found around the Pacific Ring of Fire and other convergent plate boundaries (where two plates are crashing into each other rather than moving apart)
The 1980 eruption of Mt. St. Helens, WA. The explosive nature of the eruption was thanks to the dissolved water that helped form the water in the first place (photo attribution: U.S. Government)

So, now that you’ve had a bit of a geology primer (whether you wanted one or not!), back to the game… So, I wanted a fun and interactive way of allowing players to manipulate pressure, temperature and water content and discover what it does to the mantle (solid vs liquid). I had the idea a long time ago to use bellows and a fire for the temperature control, and this week I built that out as a bit of a prototype.

Making FIRE!

Since it had been a while since I’d been in Unity, I wanted to get myself back into it gently (I find that I develop some developer anxiety if I’m away from coding and components for too long), so started with learning how to use the particle system to make fire. I found a great tutorial on Youtube by Sirhaian’Arts and after a little fiddling to get the do the texture painting that he did in Photoshop using Krita, I was able to come up with something I was really happy with.

Modelling the bellows

Once I had made the fire, it was time to model the bellows. I actually really love building models in Blender – I think I have more natural tendencies towards the visual arts than I have ever let myself accept. I found a simple clip art image as a reference and made a fairly simple mesh for the handles, nozzle, and bellows “accordion” (the bit between the handles that moves as you squeeze – no idea what else to call it). I added some nice textures and was pretty happy with the result.

Animating the bellows

A set of bellows that don’t expand as you move them aren’t that realistic, so the next challenge was working out how to animate the accordion bit. In general, I have found the internet to be incredibly helpful in helping to solve these little challenges, but in this case, I simply did not know what to search for. I tried “deforming meshes”, “squeezing meshes” and many more before I very luckily (and I have no recollection of how I got there in the end) landed upon Blend Shapes (Unity) and Shape Keys (the equivalent of Blend Shapes in Blender). Blend shapes allow you to blend between two meshes, to smoothly transition between them. Moreover, they are shockingly easy to implement. All I needed was a “wide” and a “narrow” version of my bellows accordion, and with a total of four clicks of the mouse, I had a model that would seamlessly expand and contract simply by moving a slider. Have I mentioned before how incredible these programs are? You have to be a bit careful when you’re transferring from Blender to Unity, but even that was very simple (thanks to this great video tutorial from Clayrain Digi Fun)

Adding the hinge joint

Once my model(s) were imported into Unity, I set about making them functional. This required the addition of a hinge joint and a number of colliders and rigidbodies (colliders and rigidbodies are bain of my existence despite the preparation I did for my Unity Associate Programmer Certification exam). I was able to look back at the lesson on hinge joints from my Circuit Stream XR developer course and actually it was fairly straightforward and since I have a lever in the elevator console, I already had the appropriate scripts written (although it can be quite fiddly to get the settings – particularly the limits of the joint).

Connecting the hinge joint to the blend shape animation

Of course, having a set of bellows with a gaping hole running through the middle as you move it wasn’t going to cut it, so I needed to find a way to have the angle of the hinge joint control the blend state between the “narrow” and “wide” meshes. Again, because I have a lever in the elevator that controls speed using the hinge angle, I was able to repurpose that script to convert the lever value (a number between 0 and 1 that describes where the lever is relative to its minimum and maximum limits) into the blend value (conveniently, also a number between 0 and 1). These scripts compiled straight away and worked somewhat how I intended, but there was a weird issue with things being a little bit out of sync…

With some gentle pondering, I realized that this was because of where the rotational axis was on my blend shape model – it was expanding symmetrically, when I needed to expand asymmetrically. The solution was to go back into Blended and make some quick modifications to the model so that the accordion expanded from an edge rather than the middle. And hey presto! It was looking pretty good. But, I hadn’t yet tested it in the headset, so I didn’t want to get too excited (but I totally got too excited).

A bit of polish

I wanted to add a couple of finishing touches to make it a little more  fun. Primarily, I thought it would be neat to add a puff of air each time you squeezed the bellows together. This required a combination of a modified version of the fire particle system and a simple control script that checks if the hinge angle decreases between frames (an indication that the bellows are being squeezed) and if so, triggers a particle burst. I am still not totally happy with the particle system configuration, but the control script is working very nicely.

Making it work in VR

Of course, all of this is pointless if you can’t make it work in the headset. I was so confident that it was going to work perfectly first time (yeah, right), but my aforementioned issues with colliders and rigidbodies scuppered my optimism and several hours of frustrated fiddling ensued. It turns out I was being a little bit hard on myself and my Physics Engine skills, and the things that I wanted to do with my hinge joints (i.e. have them move around in space but still act as a locally constrained system) is actually quite difficult, so I decided to cut my losses and have my bellows remain stationary – it actually makes sense from a game design perspective and I think I was only trying to figure it out for the sake of figuring it out. Anyhow, I’m really pleased with how it turned out.

I just want to add a small script that increases the scale of the fire each time the bellows are squeezed, but this will also be a small modification of an existing script so I am not anticipating too many challenges there.

The next adventure will be the pressure control interaction – I think I’m going to use an old-fashioned screw press.