PRODUCTION - WEEK EIGHT

Monday 22nd - Sunday 28th of April

For week eight, I will add more assets for the map in the game and texture them. I will ensure the textures work properly and make sure to prefab the objects. I will work on the first part of the final gun scripts and player controller. Furthermore, I will work on adding the weapon switching, aiming to hit the original plan we had decided on. To continue this and work on the initial gun system with model updating. If completed, I will move on to the rest of the shooting mechanics. During this week I will also add the grenade explosion effect using the VFX graph in Unity.

Adding Assets

Rocket Launcher

To begin adding the rocket launcher, I add the textures and mesh into the Unity scene. I created a new material for the rocket launcher and began adding the textures. To the material I add all the textures, making sure they are in the right part. After I add the normal, I make sure to convert it to a normal map, or Unity will not recognize it as one. The mesh I dragged into the scene, I scale it up, making sure it is the right scale in the scene. I then add the material and make sure it looks right. 


Knife:

To start on the knife, I import the model and textures into the Unity scene. Then I drag out the mesh into the current scene, so I can see the added textures. In the folder, I create a new material, naming it for the knife. To this, I begin adding the texture maps to the texture. Once I added the normal map texture, I made sure to convert it. This will ensure the normal detail is being added because otherwise, unity will not read it as a normal map.

Rocket Launcher

Knife

Shooting System:

Weapon Swiching:

To start with the shooting system, I wanted to add the initial weapon-switching system to the game. We had planned this and talked about how we wanted it to work for the player. We as a team decided to include both scroll wheel and number key options for switching. In hopes to give the player a greater range of ways to play the game. This is also a good way to ensure the game can stay as simple as possible, as we are doing this instead of the key binds in the menu.


To start, I open the unity scene and make sure I have my weapon systems in place from the prior weeks. In the player controller script, I create a new for loop in the update function, which will be using the items list length. This will ensure that the code is run for every item in the item list. Next, I needed to check for the input, so I added an if statement that checks for the input using Input.GetKeyDown. For that line, I make sure it is using I plus one To String, ensuring that the code changes the item by one each time. If this is the case, I make sure to equip the item with the same ID as the value.


Next, I move down to the equip item function and add a line of code that checks if the current index is equal to the previous index and then returns if true. Now back in the update function, I am going to add the code for the scroll wheel control. To do this, I first add an if statement that checks if the axis Mouse Scroll Wheel is greater than zero. If so, the code will run another if statement checking if the item list length minus one is less than the index. If so, it equips the first item in the list. Then, if this is not true, it just increases the item index and equips that instead. This ensures that if you scroll farther than the list has items, it resets to be the first item. 


Next, after the first if statement, I add an else if that check is the input on the axis is less than zero. Again in this one, I add a check to see if the item index is greater than zero, if so, I set the equipped item to the item length minus one. This code sets the gun back to the first one to reset the system. Then, if this statement is false, I set the equipped item to the item index minus one.


Weapon Switch Syncing:

Next, I aimed to get this gun switching to work in the multiplayer scene using the photon systems. I will add the code to the player controller script, but comment it out. This is because I do not have Photon in the current scene, but the final one does, so it will be commented back in then.


In the script, I go to the equip item function and add a check using an if statement. This checks if the current photon view is mine, if so, it runs the code below. In this, I add the first line which sets a hashtable to a new hashtable. Next, I add a line that adds the item index using hash.Add taking in the item index and a string. Then lastly I set the local players' properties to the hash using the Photon network. Then at the top of the script, I add a new using line, adding using Hashtable = ExitGames.Client.Photon.Hashtable. To the monobehavior, I add PunCallbacks which I comment out.


Next, I added an override function that will run on player property updates using the code OnPlayerPropertiesUpdate. This code takes in the player controller as the target player and the Hashtable as changed props. In this function, check if the current photon view is mine and if the target player is the owner of the photon view. If so, the code equips the item based on the changed props integer and the item index string.

Gun Swiching!

Gun Swich Syncing!

Grenade Effect:

Next. for the week, I wanted to get the grenade explosion out of the way and get it implemented into the throwing system. The system I made last time already has an implementation for the effect, so I just need to make an object to hold one. For this, I will be using the Unity VFX graph which will have a part for each layer of the grenade explosion. To save time and not bore you, I will not go over every little value, I will instead break it down into the parts and go over the important parts.


The grenade effect breaks down into the sparks, flash,   smoke, and fire effects which I will cover here.

Initial Set-Up:

To start, I create a new empty object which will hold the effect and will be the object spawned by the script on the explosion. In the asset panel, I created a new visual effects graph and named it Explosion. I do this, so I can keep track of the item in the hierarchy. I added this visual effects graph to the object I created, ensuring it is a child object. Lastly, I opened this up and began to edit each part.


Sparks:

To start, I will create the sparks of the grenade flash. I first changed the spawn system to a single burst, so the object is only spawned once, which will be true for every effect, so I will not iterate again. This ensures the effect does not keep looping and explodes once. For the count, I add a random number and set it between twenty and thirty, which allows the effect to be different each time. 


In the initialised particle, I remove the set velocity randomly, so I can have more control in the shape. In its place, I add a set position shape sphere. Here, I set the radius to zero point one. Then here I add a set velocity from direction and speed, setting it to a random value from five to twenty. I also changed the lifetime to a value between point five and point nine.


Next, in the output particle, I set the main texture to the default particle, which will be true for all the rest of the effects. Then in the multiply size over life, I change the size to a new descending line. For the colour, I changed it to a light yellow and set the value up a few. I add a set size random with the values between points one and one. Then I add a set scale with the values being A: point two, one, one B: point eight, two, one. After this, I go into the scene and show the effect so far. From this, I change the one to point eight on the set size random. A lot of the values change slightly, but not too much to change the effect noticeably.


Flash:

I create a new spawn system tree and begin adding the components. I set the lifetime to point one on the initialised particle. For the initial burst, I set it to one as there only needs to be a single flash. I set the size to eight as it needs to be the biggest part of the effect. I change the line in multiple sizes over life to be a descending line. For the colour, I just copied it from the first effect as it can be the same.


Fire:

For the fire, I set the count of the single bust to a random value between ten and twelve. I then set the lifetime to a random value between point two and point four. I copy the set position and set velocity from the original, changing the speed from the set velocity to a value between point five and two point five. In the multiply size of time to a descending smooth curved line. I change the size to a random value between one point two five and two point one five.


Smoke:

For the smoke, I begin by copying the fire tree as they have similar effects. I changed the colour to black, as the smoke is black. I changed the scale to a value between one point seven five, and three. Lastly, I set the speed randomly between point two five and two.


Finishing Touches:

Lastly, I go back through each item and name the particle, so I can order them in the system. This will dictate the order of rendering, which decides what appears on top. I do this in the output render order with the order being smoke, spark, flash, and fire.

Grenade Effect!

Reflection:

Adding Assets:

I am happy with the assets I managed to get added this week as they look right on the scene and the textures are working well. I managed to create the objects and added them to the assets. There is not much I would have done differently, but I think I could have done them quicker. 


Gun Switching:

As I can not see the final result, yet I am not too sure how the weapon switching has turned out, but I believe it will work. I am glad I managed to get both methods of weapon switching. I would not change it, as I think giving the players many options is the best around. This is because the audience gets to decide on how they work the game. Again, I don't know if the syncing works, but it will be a great way to ensure the other players know who is attacking them. 


Grenade Effect:

For the grenade effect, I am glad about my new skills in the Unity visual effects graph. I am glad I chose to use this method, as I believe it will be the main way to do this in the future. I believe I hit my aim to learn the new tools that I had to use to achieve this effect. Looking back, I would not change the tool I used, even though am not the most happy with the final look. I think I could have got it closer to the actual look of a grenade. 


I could not find much on how to create the effect, but I could have done more experimentation to find a better look. So, looking back, I would change the final effect to make sure it looks closer to an actual grenade throw. I wish the mood boards I made could have had more of an effect as it would have improved the final grenade effect. So again looking back I would have experimented more by using the mood boards as a reference.