At its core, Engine Defender is a top-down shooter. Enemies approach the train from the bottom of the screen and make their way towards the Engine. The player's job is to ward off enemies using three main defense systems: The Primary Weapon (detailed below), Turrets, and Magic Spells. Upon completing (or failing) a wave, players return to their Station where they can use in-game and real currency to purchase upgrades for the train's weapons, armor, spells, and turrets.
Primary Weapon
The primary weapon can hit ground and flying troops with no need to adjust vertical aim, just like any good top-down shooter. Simply tap anywhere on the screen and the train will fire its weapon in that direction. Hold the screen down to keep shooting. Players can buy upgrades to improve the weapon's firing rate and damage. "Keep shooting. You've got infinite ammo!"
The Primary Weapon has not changed much in terms of functionality. The aiming reticle shows where the player tapped to aim. The red line serves as a targeting laser to help players see their shot's trajectory.
In the early prototype, all enemies and the player's bullets existed in the same y- plane, so their was no need to compensate for enemies that were flying or on the ground.
But the bad guys can fly... (warning, it gets a little techy here)
Ahh, the fun challenge of building a top down shooter! I recently encountered a major technical drawback to the initial functioning of the primary weapon. Engine Defender is a 3D top-down shooter, so the flying enemies should hover or fly at a higher altitude than the ground forces. Initially, I solved this problem by making my enemies' colliders really tall and stretch from the ground to very high in the sky. So for a while, the enemy hitboxes were much taller than the enemies themselves. This worked as temporary solution as I tested other features, but the major drawbacks soon became very clear. Due to the player's viewport angle, it is possible for a player bullet to appear to hit a badguy, but instead just go right through it with no effect because the bullet never hit the enemy's hitbox. So I used raycasting to fix the problem
and that all look like this in the editor
but players see it like this
The middle bullet, seen above, has its rays pass right through the enemy airplane, but in 3D space, the bullet travels under the plane. In the gameplay screenshot (below), you can see the black and yellow tail of a bullet that looks like it is about to hit the enemy plane. In the next frame, the game's raycaster hits the airplane and tells the game to apply damage to the enemy.