Thursday, 4 May 2017

Outside the Box Project Alpha Work - Defense Behaviour Scripts

Defence Shooting:


FirePoint is the transform that the bullet prefab will be spawned

InvokeRepeating (UpdateTarget) is in Update as we need our Defences to be constantly searching for the nearest target


Update target will store a list of all the gameObjects tagged as Enemy that enters the range value.

The forereach is calculating how far away the gameObject's tagged as Enemy are from the Defence and then in the following if statements we are checking these distances and setting the target variable to the nearest enemy.


Bullet:

Bullet script controls the behaviour of our Bullet's, such as the speed they travel and their ability to move from their spawn point at FirePoint to the targeted enemy. It also controls the amount of money the Player receives from killing the enemy and destroys the enemy instantly.

This will be updated at a later time when I have properly implemented a health and damage system for the enemies to better control the supply of money to the Player and to add more depth to our mechanics, as the bullets currently just instantly kill our enemies.



No comments:

Post a Comment