Sushi Game Jam: ArmPG!
Tags: gamedev, unity3d, games, writing
Published: 2020-02-19 23:36:51

In January, @phuson and I set out to make a game about an arm.

An [ArmPG](https://sushicodes.itch.io/armpg), if you will.

![gif of arm movement](https://live.staticflickr.com/65535/49486754512_be6d941929_o.gif)


**The Game**

Imagine that you are an arm.

A disembodied arm.

(The game isn't nearly so gory as it sounds, I promise.)

You're an arm, trying to find the rest of your body.

In your search, you've happened upon a dungeon filled with spiders.

Anybody with half a mind would either run for their life, or burn it all down... but you're an arm.  You have no mind, it got lost with the rest of your body.

So you decide to fight the spiders, and lo and behold!  These spiders just happened to be hiding all the rest of your body parts, and you must do battle in order to find yourself and put yourself back together.


**The Modeling**

The most obvious model we needed for an ArmPG is... the arm.  So that's what Son started out with.

![arm model](https://live.staticflickr.com/65535/49549692078_107086d1d8_b.jpg)
<figcaption>Is it a worm?  A plunger?  Ohhhh it's a turkey baster.</figcaption>

If this is a fighting game, then our arm needs a weapon!  Someone in our [Twitch stream](https://www.twitch.tv/sushicodes) chat suggested a buster sword, so FF-style it was.

![sword model](https://live.staticflickr.com/65535/49550193606_8952b6bbe1_b.jpg)
<figcaption>Because what every arm needs is a MASSIVE FREAKING SWORD.</figcaption>

Next up, environment!

For inexplicable reasons, Son decided to start with a scone.

Er... sconce.

![sconce model](https://live.staticflickr.com/65535/49550193726_afdf85c08b_b.jpg)
<figcaption>Now I want scones.</figcaption>

... and after all that, he didn't even use it.

He claimed he was making a dungeon wall, but we're still not fully convinced he wasn't tiling a shower.

Or maybe it's a bookshelf?

Every dungeon needs a library, you know.

![wall with pillars](https://live.staticflickr.com/65535/49550422132_3818018ebf_b.jpg)
<figcaption>Pillars?! We fancy.</figcaption>

If your goal is to find your body, you need the rest of your body to find, right?

He made the body parts...

![body parts](https://live.staticflickr.com/65535/49527569901_f530a93bc1_b.jpg)
<figcaption>No such thing as too many swords.</figcaption>

He imported the body parts into Unity...

![body parts with arm crawling by](https://live.staticflickr.com/65535/49486754292_64c65dfdfe_b.jpg)
<figcaption>Well if you're just gonna leave your body parts laying around, it's no wonder you lost them!</figcaption>

![gif of body parts and arm](https://media.giphy.com/media/eJvZA5qZefYnHFLFNz/giphy.gif)
<figcaption>Body parts. Everywhere.</figcaption>

And then spent the week distracted, playing Socket League.

![gif of the arm "kicking" the head around the dungeon](https://media.giphy.com/media/gjmRVSvj0CG75c6tuY/giphy.gif)
<figcaption>We're pivoting - this is way too much fun.</figcaption>

Luckily (or perhaps unluckily) for everyone involved, I finally managed to convince Son *not* to pivot or abandon the prototype-a-month project in order to develop Socket League.

Last thing we needed was some sort of enemy!

Son decided to go with spiders...

... and very stubbornly decided that spiders are completely fine with only 6 legs.

![arachnot](https://live.staticflickr.com/65535/49528416766_b63f6117ba_b.jpg)
<figcaption>Unspider.</figcaption>

\#arachnot

![spider with human legs](https://live.staticflickr.com/65535/49527062593_a26a93fd7c_o.png)
<figcaption>There we go. Eight legs!</figcaption>

Pro tip: if something has a lot of the same part (such as, ahem, eight legs), you can create it once and then duplicate it!  For our spider, Son created the body and one leg separately, imported them both, and then in Unity added all of the legs to the body.

(Since we are decidedly NOT pros, since this is our first prototype and we've only made [one other game](https://bifo.co/games/bobber-bop), we originally created one mesh with all the legs, until someone in chat suggested we do it with just one leg.  OH RIGHT THAT'S HOW THIS WORKS.)

Once one spider was done, Son made a few different textures so we could have different color spiders, and then resized them in Unity.  We have a variety of spiders, every type you could possibly want!

![different spiders](https://live.staticflickr.com/65535/49551781207_1edb3f1621_b.jpg)
<figcaption>SO MANY SPIDERS</figcaption>

And to finish it all off, the one feature every game spider needs - boobly eyes.

![spider with boobily eyes](https://media.giphy.com/media/PnrwIvo4zzp3rQGv9v/giphy.gif)
<figcaption>googly eyes + boob physics = boobly eyes</figcaption>

From a performance point of view, the spider and legs were baked into one mesh to optimize draw calls, which helped with performance dramatically.


**The Dev**

Let's get some models moving!

First thing we worked on was the arm movement.  We've been using the [Final IK Unity asset](https://assetstore.unity.com/packages/tools/animation/final-ik-14290) for procedural animation.  Understanding inverse kinematics and procedural animation was one of our main goals for this month's prototype.

![screenshot of arm hooked up with ik](https://live.staticflickr.com/65535/49558829922_344a28d9a0_b.jpg)

We tried out a few different solvers (different algorithms to calculate the arm/joint movement) - FabrikIK, CCDIK, and finally settled on LimbIK.  (LimbIK is the obvious solution for arm movement - after all, the arm is a limb! - but we wanted to try out the different solvers to understand the difference between them.)  If you don't use the right solver for your intended type of movement... things get weird.

![gif of arm movement](https://live.staticflickr.com/65535/49486754512_be6d941929_o.gif)

Next, we needed some movement controls.  The arm will work if you drag around the control target in the scene, but in order to play, you need to be able to use the keyboard or a gamepad to control the movement.

For this, we used another Unity asset called [Rewired](https://assetstore.unity.com/packages/tools/utilities/rewired-21676).  We use Rewired to control the position of a control target, and then created a loop in our code to control the crawling motion of the arm.  The arm will now always move in the direction of the target.

![gif of arm crawling in different directions, with sword clipping](https://media.giphy.com/media/SsOBJU1VhLJ4DqHC1q/giphy.gif)
<figcaption>The sword cuts through the ground like buttah! Wait... that's not right...</figcaption>

Just one problem - we're dragging the sword through the ground!  Just a little vector magic and voila - the sword now faces in the right direction no matter where you're going.

![gif of arm with sword in the correct position](https://media.giphy.com/media/jSDURMH1mxoOJ04E2i/giphy.gif)

We implemented jumping, dashing, swiping... TADA!  Our player character is done!

Next we imported the environment (the <strike>backsplash</strike> <strike>bookshelf</strike> wall looks so much better with proper lighting!), and baked the wall assets as long walls to keep draw calls down.

![screenshot of wall in unity](https://live.staticflickr.com/65535/49527982963_f4e8ab353c_o.jpg)
<figcaption>Hey, it's a wall!</figcaption>

... and discovered that the arm can go through walls.

Unity colliders, WHYYYYYYY.

![gif of arm walking through walls](https://media.giphy.com/media/dxg3mH7QKrxgbD2KyJ/giphy.gif)
<figcaption>Welp.</figcaption>

Okay, we can fix this.  Instead of directly changing `transform.position`, we changed that to use `rigidbody.MovePosition()` to move the arm.  This respects the colliders, and now you can't just push right through the wall.  

![gif of arm getting stuck at walls](https://media.giphy.com/media/SvXfhK3UkVZ7hcetNU/giphy.gif)
<figcaption>Stuck.</figcaption>

Let's add some monsters!  Son's model allows us to have eight-legged spiders... but how do we move all the legs?

![spider dance gif](https://media.giphy.com/media/hsmXeMSKJyHPtNiJ6w/giphy.gif)
<figcaption>*boogies*</figcaption>

Just as with the arms, each leg is controlled by inverse kinematics, using the LimbIK solver from Final IK.  I added a loop to alternate between legs, so rather than all the legs moving towards their goals at once, only the even or odd legs can move at any one moment, and then they switch.  This gets real creepy crawly.

![gif of spider walking](https://media.giphy.com/media/WtOlpN6bvdo5yNBkmG/giphy.gif)
<figcaption>Run awaaaaayyyy!</figcaption>

Then, we used the [A* Pathfinding Project Pro](https://assetstore.unity.com/packages/tools/ai/a-pathfinding-project-pro-87744) Unity asset to tell the spiders where to go.

![gif of spiders converging on arm](https://media.giphy.com/media/d9Te2MBZl3rPmSNIM4/giphy.gif)
<figcaption>help.</figcaption>

Time to fight!  The sword has a trigger collider, so we used `OnTriggerEnter` to check if the sword collides with anything on the `Enemy` layer in the game.  If so, then that spider will take damage, and we `AddForce` to throw the spider back!

On the other hand, if `OnCollisionEnter` is triggered on the arm collider by anything with the `Enemy` layer, then the arm takes damage and is thrown away from the spider.

![gif of combat](https://media.giphy.com/media/Jqy8BwuvgD2pL0oJLW/giphy.gif)
<figcaption>DIE SPIDER DIE</figcaption>

... and then we realized we needed to lock the rotation on the spiders.  Otherwise, one hit and you get some very, very drunk spiders.

![gif of drunken spider](https://media.giphy.com/media/cJT5rfahuAkIWjAX8z/giphy.gif)
<figcaption>Go home spider...</figcaption>

From there, just a few more things to complete the game.

Lighting is **everything**.  We added some light balls, baked the lighting, and then got rid of the balls... AND LOOK HOW PRETTY IT LOOKS.  It's almost like it's a real game now.

![image of game lighting](https://live.staticflickr.com/65535/49558749611_fcfaee0fd7_b.jpg)
<figcaption>Great balls of lighting!</figcaption>

Levels!  We added some ScriptableObjects for each level, that hold all the information about the waves of spiders, and the reward for each level.  Now it's super easy to add more levels or change existing levels on the fly.

![gif of spiders falling from the sky](https://media.giphy.com/media/YOjyo8nV5SaS1Q8HdS/giphy.gif)
<figcaption>This is exactly how things are supposed to work, why do you ask</figcaption>

We added Cinemachine (which comes with Unity) for camera work, so the camera follows the player nice and smoothly.

![screenshot of arm getting chased by spiders, with proper lighting, some ui, and swoosh effects](https://live.staticflickr.com/65535/49528518251_b83a62651b_b.jpg)
<figcaption>Uh oh.  But look how pretty the game looks!!!</figcaption>

A little UI, a few simple movement swoosh effects, and voila!  We've got a game!

![image of game progress](https://live.staticflickr.com/65535/49528518156_8ac2f57158_b.jpg)
<figcaption>Fight!</figcaption>

![image of game progress](https://live.staticflickr.com/65535/49528518126_dc3d40ddee_b.jpg)
<figcaption>Fight!!!</figcaption>

![image of game progress](https://live.staticflickr.com/65535/49528518141_0875e1a4a6_b.jpg)
<figcaption>FIGHT!!!</figcaption>



**The Future**

Since we only had a month for this prototype, there were a lot of wishlist items we didn't have time for.  We're hoping we'll be able to sneak these into future prototypes, or we might someday decide to come back and finish this ArmPG.

ArmPG Bucket List:
  * invulnerable state for player
  * more of an RPG-type of story
  * finite state machine (chase/attack, idle, roam) with procedural animation for each state
  * be able to chop off spider legs
  * add blood trail
  * particle effects
  * raycast for spiders' feet to check where we're moving feet to
  * procedural environment (at least randomized drops)
  * treasure chest for body parts
  * armor/other pickups
  * sound effects/music

![gif of gameplay](https://media.giphy.com/media/d8zgb1rRh5KpNcabdi/giphy.gif)
<figcaption>WOOOOOO!</figcaption>

Our game prototype is available to play!  Download it at [itch.io](https://sushicodes.itch.io/armpg), and let us know what you think in the comments!

Enjoy this post?  Consider sharing it on social media - every tweet helps, and you'll have my eternal appreciation!

For more, follow me on [Twitter](https://twitter.com/sushiday) or check out my [Twitch](https://www.twitch.tv/sushicodes) [streams](https://www.twitch.tv/sushiday)!