Topdown Shooter

I love action games, and I like them simple. And by simple I mean that I don’t need a huge background for the story, or complex mechanics or austonding visuals; by simple I mean just any excuse with which I can feel the power in my hands. Non-sense, brutal, explosive power. More accurately, I love every game that can offer me such things. As an example, be it a Dynasty Warriors -or mostly any other mousou- game (not entirely an action game, but features full action packed 1 vs 1000 battles), the Ratchet and Clank series (again, not completely an action game, but I love the way I can blow things up) or some shooters like Borderlands.

I decided to try my best and make my own action game. I decided it would be a top-down shooter kind of game, due to its simplicity, featuring tons of weapons and explosions, just like Ratchet and Clank. So, basically, I wanted an excuse to code some explosions.

Character Movement

The whole system for moving characters has probably been one of the most challenging things of the project. How’s that, you ask?

Well, basic movement is not hard at all: characters can only move on the XZ plane and, at least for now, there is no jump or complex movement mechanics; plus, I use the built-in CharacterController component, so I only needed to use that. The component gives me precise movement, collision detection and sliding on surfaces all with only the Move method.

The problem came, however, when I wanted to push characters. It’s hard to see in the video, but when an explosions happens, it pushes back every enemy it touches.

That kind of things is usually handled by physics (aka rigidbody in Unity), but Rigidbody does not work well together with CharacterController. So I either had to write my own character controller using rigidbody (which I’ve done and won’t repeat ever again); drop the push functionality; make some dirty and hacky workaround using only character controller or make use of both systems.

While I know making your own system using rigidbodies would have been the best approach to achieve a fully customizable behaviour, it would have been the hardest, most tedious and time consumming solution. So I decided to go with using both systems, enabling and disabling one or the other whenever necessary.

So, in the end, I make use of the core Move method of the CharacterController and, only when needed, I switch to using the rigidbody built-in physics.

Concluding, finding the solution was the hardest part of the moving system.

Core algorithms for the character’s movement system. AddForce switches from CharacterController to Rigidbody system, and, when finished, CheckForceVanished switches it back.

Weapons

I got inspiration from Ratchet and Clank arsenal, and I have built 3 weapons to date: granades, a flamethrower and a simple gun.

Sin título

Selected weapon’s name, ammo and experience is shown in the center.

Weapons are equipped through a quick-select menu: while you press the button, the menu shows and you can choose a weapon by moving the mouse. When the menu is closed (by releasing the button, the selected weapon is equipped.

Sin título

From left to rigth, grenades, flamethrower and gun.

All weapons share one common functionality inherited by the abstract Weapon class, which holds values like rate of fire, damage, range, precision etc. but it’s up to every weapon to control it’s own specific behaviour. Every weapon has it’s own type of bullet, whose behaviour also differs from the rest.

ToDo

Although the core functionality is set up, there is still work to do:

  • AI: there are a lot of weapons for which I will need some sort of pathfinding, so it’s not only a matter of enemy AI. The rest of the enemies AI can still wait.
  • Implement the experience system. While I haven’t yet talked about it, I want every weapon to be upgraded through experience points.
  • Moar weapons, moar…

Of course, there are many more things to do, but these should be the first ones.