What?
A boss-battling game where you play as a tiny chef. Your job is to cook food and keep your adventurer fed who’s actually fighting the boss. Your kitchen tools are your weapons.
Gameplay
The core gameplay loop consists of grabbing ingredients from around the battle arena, cook them into a dish and serve it to your adventurer mid-battle. The adventurer’s health replenishes based on the quality and quantity of the dish. All this time, you need to dodge the boss’ attacks and minions.
Each boss is based on a specific ingredient and the target recipe is derived from it.
As you progress through the levels:
- More ingredients
- More cooking methods
- More complex bosses and minions
Development
Originally, this was a battle royale inside a giant kitchen, where two teams of tiny chefs compete to prepare a dish. After playing Expedition 33, I was inspired to restructure the concept around boss-battles. From day 1, the game had to support multiplayer, so I encountered a lot of fun challenges.
Slicing meshes
Slicing a mesh at arbitrary points means generating geometry on the fly. So, I needed some kind of a dynamic mesh. Luckily (albeit a bit confusingly), we have three options for Unreal:
- Procedural Mesh Component: The otiginal dynamic mesh, from UE4 days.
- Dynamic Mesh Component: Newer dynamic mesh, that integrates well with the Geometry Script plugin.
- Realtime Mesh Component: A long-supported, community-driven replacement for the other two. Claims to be more efficient and flexible.
While Realtime Mesh Component looked good, it seemed to be for more advanced cases, along with a steeper learning curve. To prototype faster, I decided on using the simpler Dynamic Mesh Component for all my slice-able ingredients. And after fiddling with world and local transforms for the correct cuts, I now had both vertical and horizontal cuts working.
Replicating slices
During multiplayer, I got some bad news: Dynamic Mesh does not replicate out of the box. Not only are the slices not replicated, but the resulting pieces’ transforms, velocities etc. are also not replicated. It’s too much data to send for each mesh, which can choke the network for lots of pieces. What this means is when a player cut a potato in 4 pieces and moved one piece away, the other players won’t see any of this development, only the initial undamaged potato.
A starting point of this is: Replicate the slice operation manually. Every slice operation has a number of parameters, like the location and angle of the slice point. When player 1 fires a slice, we send this slice operation data to other players so that their copy of player 1 fires the exact same slice operation locally. By wrapping it in a reliable RPC, the slicing order is guaranteed, resulting in equal-looking pieces across all players.
However, now I needed to solve the sliced pieces’ transforms, so that moving them around is also replicated.
Replicating transforms
There was a fundamental gap between the players: As far as the game was concerned, each piece was spawned locally. It wasn’t “linked” to its corresponding copies on other machines. I needed a way to “connect” these pieces across the network, so that when piece 4 is moved by player 1, the game is aware of other piece 4s for other players and moves them.
To start, I decided to assign IDs to these pieces, such that the IDs are consistent across players. The function SplitMeshByComponents returns all the individual pieces in an array. It internally uses triangle IDs to sort them, but this order varies across machines. So piece 4 will still have a different ID for each player. I needed a manual but deterministic sorting method.
Since each piece occupies a unique space in the world, I used their centers of masses to sort them. This allowed me to have consistent piece IDs across machines. Now, when piece 4 (say piece id piece4) is moved by player 1, the game can now find piece4s on other machines and move them in sync.
Architecture
Long story short, to manage ingredients and cooking effectively, a bunch of classes are used:
IngredientsOwner: A replicated actor spawned by game mode at launch of a level. It manages creation and deletion of ingredient pieces, and has ownership over them. It also provides mapping from a piece ID to the piece’s mesh object.IngredientManager: A replicated actor component that tracks piece IDs and their transforms. Every player has one (to track the pieces they hold) and so doesIngredientsOwner(to track pieces on the ground).SlicingManager: A replicated actor component, housed underIngredientsOwner, to pipe slicing-related RPCs.CookingProcess: A generic, replicated actor component, housed under a utensil or appliance, to represent the cooking process this utensil or appliance does. For example, an oven has aCookingProcessBake. This component synchronizes the current cooked state of pieces across players.
Boss battle
With the basic mechanics out of the way, I built out rest of the boss battle pieces:
- AI for boss: Attack adventurer and spawn projectiles at players.
- AI for minions: Spawn out of unsliced projectiles and chase players.
- AI for adventurer: Attack boss, rush back to players when they ring a bell, consume food and head back to the boss.
- Scoring system for delivered dishes, so it influcences the adventurer’s health recharge.
- Rudimentary parry system to slice projectiles mid-air.
And the playable was ready!
Demo
The demo contains 1 showcase boss battle.
Play on itch.io