Simulation is an integral part of most video games, and building AI or gameplay scripts to deal with simulated part of the world is always... interesting! Certain developers take that to the extreme by not only building their entire games around the underlying simulation, but their puzzles/narratives on top of that. In particular VESSEL, a creative and inspiring indie platformer, combines physics simulation and behaviors in its unique puzzles.
On Sunday, in a live interview broadcast via AiGameDev.com, VESSEL's Lead Developer John Krajewski (founder of Strange Loop Games) discussed his insights from the development of the game. In particular, you'll learn about building AI characters to deal with underlying simulations, but also how the puzzles were built as a combination of the two.
Screenshot 1: Particle-based water simulation in vessel and dynamic clustering of nearby drops. The clustering helps the engine (and the AI characters) understand the simulation better.
Core Simulation Mechanics
At the core of VESSEL is a custom-written physics simulation that started out with rigid bodies. However, as the game progressed, it inherited many features such as fluid dynamics, which turned out to be the core of the gameplay in most puzzles.
“The main thing we did was build the liquid simulation; it's all particle based so we all kinds of physics algorithms so it can stick to walls and emit light, etc. [...] In VESSEL, we decided to go with a particle based approach for a number of reasons, it didn't limit the scope of where the liquid could go and you can preserve mass easier. It worked better to support different types of liquid.”
As Krajewski explains further, the underlying algorithms are relatively simple but can be a challenge to optimize.
“We started with this particle simulation, and from there we'd run different algorithms over it, called pressure kernels. Each drop would look at surrounding drops, and excert a force on each of those drops. There are techniques you can use to speed that up, because it's fundamentally an O(n2) algorithm, and using pressure kernals you can make it perform a lot better.”
For those interested, here's the paper that VESSEL's fluid simulation is based on:
Particle-based Viscoelastic Fluid Simulation Simon Clavet, Philippe Beaudoin, and Pierre Poulin Download PDF
As Krajewski explains, VESSEL leverages this algorithm for more than just liquids in the traditional sense.
“And then we took that a step further to see what we could do to create characters. [...] The biggest challenge in VESSEL was creating these creatures, the Fluros. They are actually conglomerations of liquid too!”
In VESSEL, the characters themselves are built using the same principles as the characters, as Krajewski explains.
“We did different experiments of trying to integrate them into basic skeletons, having the core skeletal structure inside attract the liquid with different bones having different weights. It resulted in these shapes that were physically driven but still behaved like characters.”
By using the fluid simulation to implement the characters, this had many benefits for the gameplay. When a Fluro bumps into something (or the player) it will physically respond, undergo a chemical reaction, and often even disintegrate.
“That really connected the AI with the physics of the game, because these characters have a lot more simulation to their bodies than normal characters in games. Every particle inside of them was part of their body and influences their AI. [...] It's what we wanted to focus the game on as well, so all of the puzzles in the game came out of that interaction.”
Understanding the Simulation
If making the characters fully simulated was not enough, VESSEL needs to also have each character understand the physics of the world and behave accordingly. Krajewski uses examples to emphasize this point.
“These little creatures are attracted to light, wherever it is in the world. In this case, the player is holding a light which the Fluro can't reach so it'll run underneath you. [...] We implemented that using light-meters and a manual path graph system. Every few meters in the dark levels, we'd have to manually place light meters which evaluate the nearby lights every few frames. The light Fluros never queried teh lights themselves, it always went through these light-meters.”
The screenshot below helps illustrate the path graph and shows the Light Fluro in action.
Screenshot 2: Debug visualization of a Light Fluro pathfinding towards a light-meter that's activated by the lamp the player is carrying.
Similarly, another Fluro in the game, called the Drinker, had to dynamically interpret the surrounding world to identify clusters of water and figure out how to reach it dynamically.
In the rest of the interview, for which the replay is available here, Krajewski digs into many aspects of the game both as a Lead Programmer and as a Lead Designer.
- How the Fluro's predictable behaviors are built using behavior trees.
- What tools were used to support the level design and development.
- How the puzzles were built in a very bottom-up experimental fashion.
If you have any further questions about VESSEL and its underlying simulation of fluids, physics or characters, don't hesitate to post them below or in the forum thread!