Week 1 Developments (Devlog)


Tasks Undertaken:

- The creation of a WeaponBase class was the primary task for the week and has the purpose of functioning as a parent class for all inheritance-based weapon sub-classes. A more unique approach for creating a parent class that allowed for inheritance for children was the use of the the abstract method. This could not receive any information within the parent class however excelled in child classes that required the method for functionality. This was strictly for child classes receiving their behaviour from the WeaponBase class. This allowed all child classes to maintain the same functionality and variables whilst saving an incredible amount of time and code required between each one, being the most viable method for concision. 


- The creation of this class included a large number of the Weapon Attributes which alternatively could have been filled out in a separate class, but in this circumstance it was done for ease of understanding for myself to get an idea of the Weapon variables that would be necessary. It was also done in a format that could easily be concatenated into a separate class if necessary.  A series of the variables were written out with parameter fields that were implemented if they needed to be altered later for extended functionality. Like some of the enumeration and other variables this is considered static code that will need to either be rewritten and altered for extended functionality.

-  It was decided to implement a simple instantiating script and the Ammunition functionality once we have implemented the UI to function by subtracting the difference from the maxAmmo and adding it into the current magazine/clip. By going a bit further with these test scripts I was able to get rough estimates for functionality and how to implement the Ammunition script in tandem with the WeaponBase/Inherited scripts once completed.

- Integration of a raytracing process within the update script was also implemented however was unable to be tested due to conflicts with the master file for the project. The purpose was to allow the weapon to have some movement when moving the cursor around the screen for the weapon for added realism. This will be further tested in future development stages however could prove complicated as it expects rotations and values of all objects to be set to 0 and it has been observed when imported assets are placed within Unity, they have modified default rotations.


Obstacles:

My primary struggle was looking at the necessity for separation of the Attributes and WeaponBase class and how they could be united into one class for ease of use, which does result in a more verbose set of code within a singular script however allows all of the functionality to be editable when necessary and derived for any sub-class. 


Solution Reasoning:

- The abstraction method is one of the more unique approaches for coding having never utilised it before, however after some research it was deemed the most advisable method  for inheritance classes. Interfaces were a close second when it came to creating inheritance classes having utilised them in prior game projects. Whilst inheritance con modify the parent and has multiple implementation capabilities on a single script , the abstract method save extreme time and code between each child class.  The only method *required* within a child class is the ShootWeapon method which is independent in each class allowing for variable functionality. The format in which it is implemented is within the Fire method so that they will trigger concurrently. Testing of this process proceeded with different Debug log prints to show that different weapons were working once the prefabs were created.

Leave a comment

Log in with itch.io to leave a comment.