Final Project Week 1 - Visual Weapon Handling



Welcome to the first post of my final project. The goal of my final project is to create a modular weapon system that can be used in first person shooters. I plan to make it as accessible as possible, so developers can import it into their projects and have a fully functioning modular weapon system that will allow them to use their own models to quickly and simply set up their game.

This week I focused on setting up the project, creating the core shooting system and setting up a lot of the visual handling mechanics.

I started this week by creating a GitHub to store my project, you can find it here, I will be updating it regularly with the progress I make over the next 5 months. I'm using Unity to create my project because I am very familiar with it and I will be able to most efficiently make my project using C#.

After creating the Unity Project I imported an FPS character controller that I created in the past, I'm using this rather than the Unity standard assets controller because I want to be able to focus on creating my weapons system, without having to worry about how to work the character controller if I choose to make changes to it or access some of its variables.

Shooting

Now that I had the groundwork of the project, I added in a weapon model and started creating the shooting system. I knew that I wanted to use hit scan to determine where the bullet lands. This is because I want to be able to focus on how the weapon handles rather than how the bullets travel. I also want this system to be have a focus on being used in fast paced games and I feel that having bullet travel adds something more that the user will need to think about before firing making is slower to use.

I used Unity's ray casting, firing from the centre of the screen, directly forward relative to the camera, using this I was able to then check if anything was hit. I set up debug rays to help me visualise this in the editor (Seen below). Getting this set up was good as it allowed me to be confident that my system was working and if I have problems in the future with shots not working as they should, I can refer to these debug rays to quickly see if the ray casting is the issue. The firing is handled with a simple delay between shots, next week I will go into making the fire rate and fire mode easily editable by other developers without having to go into the code.

Showing the debug rays when fireing

Next I wanted to make it obvious that shots were happening without having to look at the scene view to look at debug rays. I did this first by spawning bullet hole textures at the points of impact to make it clear that shots are hitting. Next I added muzzle flash to the weapon, this allows the user to very easily see that the weapon is firing, even if the shots dont hit anything or the hits are too far away to see.

Weapon Clipping Issue

While I was playing around with what I had, I found an issue with the weapon clipping through walls, this is an issue because you always want to see your weapon, even if it physically doesn't make sense. To fix this I had to make a separate camera that would only see the weapon, and objects attached to the weapon, it then overlays the weapon on top of the main camera. This means that even if the weapon is actually clipping through the wall, you can still see all of it.

Using a single camera causes clipping issues Using a 2nd camera removes the clipping issue

This actually had an added benefit that I didn't plan, using this system allows me to change the Field Of View (FOV) of the main camera without distorting the view of the weapon. This means that the user will be able to change the FOV according to their preference and it will have no effect on the visuals of the weapon.

Weapon stays in place while main FOV stays the same

Weapon Sway

Now that the user can shoot and move around. I wanted to start making the visual handling of the weapon, this will only effect the way the gun moves without having any effect on the actual characteristics of the weapon.

I started with the positional sway of the weapon, this means that when the player looks around, the weapon will react to the movement giving the illusion of the weapon having weight. I then moved onto adding rotational sway, this gives off the sense that the character in game is leaning into the turn, making the weapon feel more alive. I wanted to make sure that both of these are easily adjustable so I made sure that there are 2 variables, one to control the positional sway, and the other to change the rotational sway. This allows the developer using the system to make it feel unique to their game.

Implementing positional sway Adding rotational sway

Playtesting

When I had all of this set up I asked some people to test the system and asked for any feedback on how I could improve the feel of it. Most feedback was along the lines of "can you make it faster", or "Can you make it move more", which is easily changeable. One piece of feedback that I thought made a lot of sense was, "You should make it tilt when you strafe", which was a great idea. I already planned to implement weapon bobbing, but this would act a lot like the rotational sway where it would lean into the movement, so I decided to add that next. I made sure that the amount of lean is adjustable, and I found that to be a very nice addition to the system. I also decided that I would add sway when jumping, this will give help the player to see their current vertical momentum, while also giving the illusion of weight in the weapon.

The weapon leans into a strafe Vertical sway while jumping gives the illusion of weight

Weapon Bobbing

Next I wanted to add weapon bobbing so that it looks like the character is walking, and it is effecting the weapons movement. One method to do this is to create animations, but the problem with animations is that they take a long time to make, and if you would ever want to change the feel of something you would need to change the animation, but I want my system to be easy to set up, and quick to make changes.

To achieve the ease of use I wanted, I have made the weapon bobbing system adjustable with 3 values, horizontal amount, vertical amount, and speed. The amounts will change how far the weapon will actually move on the screen, and speed will adjust how fast it will get to those amounts. These 2 values together can completely change the feel of the weapon. For example, having the weapon move a lot, and very slowly can make the gun look heavy and cumbersome, where as if the gun moves a little, very quickly it will feel a lot lighter.

Moving the Weapon slowly makes it appear heavier Making the weapon move faster makes it appear lighter

Readability

The last thing I did was make sure that all of the variables in my inspector were easy to read and understand so that a developer would have no trouble finding and adjusting the values that they want. I also wanted to make sure that the values were a reasonable amount, for example, up until I went through the process of fixing this, to get a reasonable amount of sway, the 'SwayBounds' would need to be set to -0.03 and 0.03, and the 'swayMoveAmt' would be set to 0.0015. Writing these numbers isn't really an issue, but it is a lot more user friendly to use whole numbers, or numbers to 1 decimal place, I also tried to make it so that the default values could all be set to 1, and have a reasonable amount of movement.


The only exception to this is the 'hipPosition', this is because it is an offset used to set the position of the weapon, this is necessary because not all weapon models will be the same size and their centre point will be different, this means wouldn't all look good in the same position relative to the camera. I created this value to allow the user to adjust the offset, I wanted to keep this 1:1 so that the user can play around with the values to keep the weapon in the correct position.

I feel that I have made good progress this week. I got a lot of features into the visual handling and even managed to get some good playtesting feedback that helped me add features that I had not thought of myself. Next week I will be working on the different characteristics including fire rate, fire mode(single, burst, auto), and ammo count.

The GitHub for this project is available here: https://github.com/ElliotChester/Modular-Weapon-System-Final-Project

I'd like to thank James Thirlwell for allowing me to use his M4 Carbine model in my project. You can find his work here: https://www.artstation.com/jamesthirlwell


Bibliography

Wagar, C. (2016). Hitscan versus Projectile weapons. [online] CritPoints. Available at: https://critpoints.net/2016/07/27/hitscan-versus-projectile-weapons/ [Accessed 16 Nov. 2018].

Giant Bomb. (n.d.). Weapon Bob. [online] Available at: https://www.giantbomb.com/weapon-bob/3015-5831/ [Accessed 17 Nov. 2018].

Houghton, D. (2014). Killing feels: The importance of sensation in video game weapons. [online] gamesradar. Available at: https://www.gamesradar.com/uk/killing-feels-why-sensation-using-game-weapon-more-important-its-effect/ [Accessed 17 Nov. 2018].

Comments