Holiday Programming April 2017

During one week of the Easter holidays, I decided to program a small C#-driven game in Unity. Sadly I can’t spend a lot of time programming and making things while still busy studying Japanology at university, but holidays are the perfect time to switch gears and get back into sharp 🙂 Recently I had played Nier:Automata and the game featured an addicting hacking mini-game in the form of a twin-stick shooter. During fights, you could “hack” enemies to damage them, and hacking involved shooting black sphere enemies who moved around and fired either orange or purple bullets at you.

I was impressed with how many different mini-game combinations there were and how it blended in beautifully and fast with the game’s action-based combat. I really wanted to try and recreate some of the simple levels of this mini-game (see screenshot on the left), and see how far I’d get in one week, with the intent of maybe polishing it up during the summer holidays to put on my portfolio. One week of the holidays was spent on playing Persona 5 and another one was spent on recreating the hacking game. Here’s a short video clip of what I made:

My main personal goals for this project were:

  • Keep it simple, try to make use of what Unity provided for you. (coming from XNA I sometimes have trouble with that) but still try to tailor to many different gameplay scenarios.
  • Try to implement a minimum level of polish to make it look somewhat okay.
  • Extend the Unity editor for level tools and quality of life improvements.
  • Simple, readable code and Unity properties.

Outwards, the game features a player, controllable by keyboard and PS4 controller, multiple levels with their own enemies and win/victory conditions. From an editor perspective, enemy behavior is easily adjustable via many parameters, and I’ve tried to make simple systems for level switching, camera zooming and callback handling when objects are destroyed to enable rich scenarios in a simplistic manner. Tracks that enemies use to move over or shoot bullets from can be manually adjusted and I extended the editor in ways that this became relatively easy and visual. (Although I could’ve probably used something like iTween in the end).

Movement is key to this game and moving and rotating went through a number of iterations to get something fast and responsive while feeling intuitive and easy to grasp. Both keyboard and a PS4 controller are supported of which I did PS4 controller support first. I mapped it exactly like how Nier did and it felt really good. Mouse and keyboard movement took a bit more iteration that worked well even in fast-paced scenarios.

I think the biggest hurdle was rotating the player towards the direction it was moving (with the arrow keys) but at the same time rotate towards the mouse pointer when you’re shooting, while the player keeps moving in the original (arrow key) direction. Not to mention that there are many ways to do translation and it can get tricky fast, something I definitely have experienced.

I decided instead of breaking enemies up in different classes and sub-enemies, to create one big class that would handle the enemy’s shooting behavior (BulletDistributor.cs),  The class handles spawning bullets on a path or towards the player with plenty of editor options to cater to different scenarios and this can be changed on the fly to allow for various unique enemy variations as seen below.  Furthermore, this could allow enemies to change behaviors completely mid-battle.

There’s definitely room for more improvements (especially when it comes to scaling, snapping to a Y-axis or creating richer and prettier levels with sound effects, lasers, and Michael Bay-like explosions) but I’m glad about the way it turned out in just one week.  People who want to mess around with the project themselves, the code in available on Github.

I’ve also updated the layout of this blog, closely resembling my Japan-oriented blog. Japan on there, programming on here.

Now, I should be studying for the upcoming Japanology finals next week, and hopefully, reach Warning Level 3. 🙂

Thanks for reading, Nick
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s