Porting "Car Jumper"

In light of all that's happened in the Unity scene with the release of Unity 5, and the announcement of the Unite 2015 conference in Boston, now was as good a time as any to drop everything and port our OUYA build of "Car Jumper" to the iPhone 6.  My goal, by the end of August, is to have multiple demos running on the device, so that I can spend the bulk of September simply polishing what's already stable.  In an effort to have something running and playable as quickly as possible, I've dragged-and-dropped the assets into a new Unity iPhone project, gutted out all of the OUYA controller wrapper code (well over a thousand lines across 3 scripts), and started rewriting and reintroducing elements one at a time.

This is has been a brutal experience. 

Starting with the basic mechanic of jumping cars for point, I stripped out all of the character control logic and started from scratch to introduce touch input.  I took this time to completely remove the useless ability to "Run", and rebuilt the vehicle rigs to accommodate actual suspensions and wheel physics(the spinning wheels were strictly decorative before).  Seeing as this is a mobile build, I introduced a timer to increase the number of play sessions and tighten the gameplay loop, as it was possible to play a single session for several minutes on-end without a time limit.

Same OUYA exterior (for now), but pretty much everything behind the scenes has been gutted and rewritten/rebuilt from scratch.

Same OUYA exterior (for now), but pretty much everything behind the scenes has been gutted and rewritten/rebuilt from scratch.

Once that was all working, it was time to tackle something I'd been putting off for the entire life of the project: efficiency.  From its inception, "Car Jumper" was always going to employ a randomized element to keep gameplay interesting.  My initial prototype and subsequent OUYA release, however, utilized a brute-force Instantiate/Destroy method of randomly populating the game.  This worked as a proof-of-concept, but consistently caused performance hiccups(Even on my Mac Pro).  I finally sat down and implemented an object pooling system for the iPhone version, in an effort to maintain the element of randomness, without killing gameplay or battery performance.

This proved to be an interesting challenge, because each randomized element required a different implementation.  Background elements were the easiest, because I could just randomly populate a list and the repetition wouldn't matter.  Power ups and vehicles, on the other hand, still required weighted randomization, due to certain power ups and vehicles being more valuable than others.  

After the core pooling was set-up, it was time to start reintroducing powerups.  The "Score" and "Jump" boosts were basically untouched, save for a few changes to accommodate a modified character controller and a completely new API for the GUI.  The formerly useless "Bullet-Time" power up was replaced by a power up that adds time to the clock, which allowed good/lucky players the opportunity to push their scores even higher.

Complicating matters was the fact that I had to figure out how to make the "Berserker" power up work with object pooling.  I wrestled for a while with a convoluted pairing system where a vehicle and its corresponding wreck were instantiated together and a "Berserker" collision would just toggle the active/inactive objects, but finally said, "Screw it", and added a pool of random wrecks.  Now it's possible to run a "Berserker" into a motorcycle and produce the flaming husk of an SUV(and vice-versa).  It's so stupid, it actually works. 

The only thing really lacking from this otherwise very functional OUYA-to-iPhone port is visual feedback on powerups.  Due to the new GUI system introduced in Unity 4.6, all of the powerup-related GUI elements need to be rebuilt and rewritten.  That will have to wait, as it's currently "Good Enough" to leave alone for a while as I start porting my top-down shooter prototype to iPhone next.