Drone Destroyer

Defend your city from an alien race.

Development Walkthrough

Turret Rotation/Movement:

Allowing the turret to move, yet be restricted via rigidbody and transform constraints and managing. On update the transform of the player turret is updated to the mouseY and mouseX variable. The minimum and maximum transform clamp prevents object clipping and unrealistic angles.


Firing the turret/guns:

Firing a raycasted shot when mouse 0 input is detected. Whether this be a single click or holding down the button. This raycast then determines if it hit an enemy prefab, if so it then causes damage to that instance.

8
The raycast is fired through children of the turret object.
9
The Raycast is created and applies damage if it hits the enemy object.

Enemy spawning and movement:

Enemy spawning is controlled by a spawn container in which a timer instantiates the enemy prefab which then targets an arbitrary building. To avert errors when a building is destroyed a Try Catch is called within update to check if the currently targeted building still exists within the scene. If not, then the enemy object targets a new existing building to attack.

6
This graph is connected to an object spawner in the level which instantiates an enemy prefab every five seconds.

Pickups and turret firing power:

The turrets firing speed is controlled through an integer, this variable can be changed at any moment to reflect a power up that the player has collected. Here the custom event called “FireRateUp” sets the fire rate of the players turret for 10 seconds after the player has successfully hit the falling powerup.


12
The collection of different processes strung
7
This represents the Try Catch that each enemy prefab instance uses to determine if the building they have targeted has not yet been destroyed.