Week 2 Development (Devlog)


Tasks Undertaken:

- The primary task for this week was ensuring that the Bullet prefab could be easily instantiated by the WeaponBase script and all inherited classes and propel itself forward with the set variable of 'speed' (Velocity) that was assigned by Mitch. The instantiation code was implemented directly in the Fire method within the WeaponBase so that it could work between all inheritance scripts whilst also utilising the shotRate effectively for time between shots. The Fire method caters particularly to the PlayerController and reads for the Fire1 input (Mouse LMB) before reviewing the amount of munitions the player has and then firing. The maxAmmo and currentAmmo was utilised within the AddAmmo method so that a reload function could be implemented at a later stage with relative ease. For testing a GUI output was also coded so that information could be read on the Player's HUD.

 - Initially new variables for the WeaponBase were created including the projectileSpawn (Transform) and projectile (Rigidbody) so that an instantiation location and assigned rigidbody could be set within the editor. Setting the projectileSpawn in an accurate location required integration of an empty game actor that was made a child and re-located in front of the barrel to ensure that instantiation was in the most viable location. 

- The rigidbody being set required an instance of the Bullet prefab to be placed somewhere within the scene in which the rigidbody data would be read from. With the Bullet prefab already containing the propulsion script the test weapon was able to fire after integrating the Assault Rifle Base and setting the necessary variables such as shotRate and assigning the projectileSpawn and projectile.

- After ensuring complete functionality withe the bullets from the test weapon, a series of additional weapon prefabs with varied fire rates, damage outputs and other variable information. This would ensure ability to adjust multiple weapon types once Health and other script components were implemented.

Solution Reasoning:

-  One more unorthodox approach that is notable would be the use of Rigidbody data for firing bullets  which required an instance of the bullet to be sitting within the scene at all times. This was done to enable precise physics-based rigidbody data to be returned rather than complete game object data allowing for suitable velocity functionality and propulsion from the weapon which could be easily modified for the alternative projectile types including grenades, rockets and ballistics.

- Whilst having the abstraction method for ShootWeapon was a completely viable process for implementing firing between all scripts, it does not allow code to be listed in the parent script and writing the Fire method in all scripts within each inherited class would overpopulate aforementioned scripts with unnecessary code. It is decided that this could be re implemented within the abstract methods of each child class if unique functionality that is particular to that weapon is to be implemented when firing.

Leave a comment

Log in with itch.io to leave a comment.