PRODUCTION - WEEK NINE

Monday 29th - Sunday 5th of May

Here in week nine, I aim to complete my shooting mechanics from last week as well as any other aspects of production I can manage to get done. For the shooting system, I aim to get the damage done and finish the multiplayer syncing. This week I aim to complete all the production if I can. There may be more later but it will be from issues that arise from the later weeks. I will also add more assets from weapons to map assets. 

Adding Assets:

Grenade:

To start with the grenade, I wanted to get a bit of organization into the scene. I have a new folder for the grenade prop and flash bang. I drag the old grenade and the flash bang into the scene with the current textures and mesh. Furthermore, I created a new material for the grenade mesh and began adding the texture maps. For the normal, I make sure to convert the texture when I did it, so Unity can read it as a normal map. I add the object into the scene and scale it up to the right size. Before I do it, I fix the pivot by moving the child object in the parent. I add the material to the object, making sure it looks right. 


FlashBang:

Next for the assets, I wanted to begin adding the flash-bang final model into the unity scene. I will replace the cylinder placeholder on both the head model and the flashbang projectile. To start with this I first have to add the model files in the final scene. I then create a new material for the flash bang and begin adding the texture maps. To the normal map, I change it to the normal type so Unity recognises it. I add the rest and drag in the final model. I make sure it is the right scale and add the textures. I make sure they look accurate before I move on the the next stage.


For the handheld model, I remove the cylinder and drag the new model onto the object. Again I ensure it is the right scale and position although it is up to change later in the final project scene. I remove the old model after coping with its position in space. I moved the flash-bang prefab into the final scene and changed the model mesh to the flashbang mesh. I tried changing the collider and ran into some problems with the bounciness. To finish it off I add the collider back to fix this using a capsule collider.


Map Ground:

Next, I begin adding the mesh for the floor. This is the underlying map floor mesh that all other objects will be on. I drag the mesh into the scene and change its scale. This will change in the final scene to fit the final player scale. I created a new material and named it currently to help keep the files sorted. I add the maps to the object, adding each map in the right spot. Furthermore, I add the normal map to the material, making sure to change it to a normal map. This ensures that Unity and the material read it as normal. Then I drag the material onto the object and create a prefab using it.


Building One: 

Next for the assets, I will add the first building made by Kyle. This will be one of the main parts of the map and later added to it. To make talking about it easier, I made each material in the same way, following this process. First I created a material and named it after the object it is for. Then I add all the material texture maps, making sure to put them in the right spots. For each normal map, I make sure to change it to a normal texture in the unity inspector, so Unity recognizes it as one. I do this for each object, starting with the windows. Some objects have different properties based on the material it is, which I will go over now. 


For the window glass and the door glass materials, I make sure to change the texture surface type to transparent. This makes it, so unity recognizes the material as a transparent material.

Grenade

Flashbang

Ground Mesh

Building One:

Shooting Systems:

Part One:

To start on the shooting system, I need to convert the old item script to the abstract class. Then I added a new abstract void Use, this will be called in later code to control the shooting. Heading back into Unity I create a new gun script and open it in Visual Studio. In the script, I change it to an abstract class and make it derive from the item class. For this, I removed the mono behaviour and replaced it with the item namespace. I remove the already included function and add an abstract override use method, which when called will override the item use function.


Then back in Unity, I created a new script called single-shot gun. This will be the main script controlling most guns. Again, I removed all the other functions and made this script derive from the gun script. To get the script to not throw an error I make sure to add the use function in. For now, I added debug to show the name of the used gun currently.


Now back in Unity, I go over the new scripts, filling in the details missing in now. This is because changed the system, so the scriptable object slots are all empty. I do this for every gun, making sure to add the mesh item and camera. I added the rocket launcher mesh to the object, as it was missing as well.


Part Two:

To start the implementation of the shooting on the player controller, I added a new input check-in update. To this, I call the item list using the item index calling the use function. This allows the player to shoot when the input on the mouse is detected.


Back to the single-shot gun script, I added a shoot function and called it in the use function made previously. To the shoot function, I add a ray that will be from the camera using viewport point to ray. This takes in a new vector of 0.5 on all values. Then I set the ray's origin to the camera position. After this, I check if the raycast hits using physics.raycast taking in the ray and a new hit. In this if statement, I add a check if the hit collided with an object holding a damageable component and if so, it will call the take damage function on a new script.


To get this working, I created a new damageable script in Unity and opened it in Visual Studios. In this script, I add a void to take damage and add a float for the amount of damage to take. Now each gun will need a damage value, so in the gun script, I add a public float which will be the weapon's damage. Now back in the single-shot gun, I make sure this takes damage is using the gun info damage float. This will ensure that the guns all do different amounts of damage to the player.


Back on the player controller, I add damageable to the monobehavior but keep it commented out. Now at the bottom of the player controller script, I add a function for taking damage using a float for the damage value. In this function, I call take damage on a target using the PV.RPC. Then I create the void RPC to take damage and check if the photon void is not mine, if true, it returns. Now at the top, I add a float for the max and current health, so the script can keep track of the current stats of the player. Then in start, I set the current health to the maximum health, so the player starts with the maximum health.


Now back in the RPC function, I add a current health minus damage line, so the script can deal some damage. Then I add a check that sees if the current health is below or equal to zero, and, if so, it calls the die function. At the top, I added a reference for the player manager and I set it in the start function. Then in die, I call the player-manager die function.

Gun System - Part One:

Gun System - Part Two:

Reflection:

Adding Assets:

For the assets, I am happy with how they look, and the textures translate well to Unity. The textures look good on the models and I cannot see any artefacts. I think I could have added the assets quicker in Unity and got on to the other parts quicker. I learned more about textures in Unity as some materials were transparent. This was fun to learn and will help me in the future of making games. 


Shooting:

For the gun system, again like last week, I can not tell if it works until it is added to the multiplayer environment. But I can tell it is a complicated system, so I wish I could have found a simpler one. The series I was following ended around this point in the system, but I feel more parts should be added. Many aspects are missing, like reloading and fire rate. Looking back, I wish I used the other series for the mechanics. This may have led to a better, more thought-out system.


The reason I picked this as the series was because of the infrastructure of the gun item system. I do like this aspect of the item class and each one has certain aspects, but the rest is missing. I do not believe the structure makes up for the lack of necessary features. So, looking back, I wish I could have added more to the system and improved the final product. So, moving forward, I will make sure to analyse closer and make demos using both systems. This will ensure I can tell the downfalls before I have no options left.