Modular Shooting Mechanism

During school I’ve made multiple shooting games, but for the most recent fps I wanted to step up the shooting mechanic. So I ended up asking my friends who play a lot of different ones which one felt the best. With their feedback I decided to look at Borderlands 3 as the main reference while also looking at some other games for small changes.

I took the spray the recoil and the way the gun itself moves, and made it into this modular gun mechanism. And most friends who used it really liked how it ended up.

This script was part of the Spaceman project I made for my school exam. You can read more about the project itself in the projects tab.

 

Weapon Feel

When making a shooter guns are somewhat important, so it’s a good choice to make them feel good. As my main inspiration on how to make them I used borderlands 3. I booted up the game and made notes on every small detail on how they worked.

The biggest factor on how the weapon feels is how it sprays. So in short, how the spread and recoil works. The spread is simple, the longer you shoot the worse the spread gets untill it reaches a cap. When you stop shooting it will go back to it’s default spread. Scoping with a weapon just reduces the spread overall.

The recoil is a bit more tricky. I made it so when you spray the camera kicks up, and then a randomized value to the right and left. This also gets a buffer so when you spray long enough the recoil gets less and less. Then when you stop spraying the camera should return to it’s default position. For singlefire weapons this could be it, but when spraying with a weapon you are probably going to counter that recoil. So I added that when you counter the amount that you counter reduces the amount the camera goes back down. Otherwise everytime you are done with spraying you would look at the ground.

Now that the feel is there functionally you still have the gun itself that should react to you shooting it. I did this by setting a centerpoint on the gun. And then you have values on the gun that effect how it reacts. These are how much the gun kicks back, how much the gun rotates back, on how it rotates to the sides. The gun will always return to the main location with a lerp. When scoping these values will also be reduces.

Modular

On thing I always try to do when possible, is to make something as modular as possible. So with weapons I also applied it. With that said everything is customizable. The basics like damage, firerate, recoil, etc.

But I also added other values like the bullet count, multiple projectile types like raycast or a prefab, and also multiple fire types like singlefire, burst or autofire.

With this you can apply this script on most guns and change them to your liking.