Tutorial - Make a ScriptableObject-Based Gun System from Scratch

Hey all! Happy #TutorialTuesday!

This week I’m kicking off a new series about guns! If you’re going to have more than a couple of them in your game, you’ll likely find a prefab-based workflow becomes cumbersome to keep cleanly structured and in sync as you extend functionality, add VFX, and want to reuse configurations. Learn how to make a highly configurable ScriptableObject-based gun system from scratch!

In Part 1 I cover covering the base setup of hitscan guns starting with 3 scriptable objects:

  • Gun Scriptable Object - holds the model, does the shooting
  • Shoot Config Scriptable Object - holds how the gun will shoot
  • Bullet Trail Config Scriptable Object - holds how the gun trail will appear

Here’s the Series Playlist:

If you have some other suggestions for content to be added to the playlist, leave a comment here or on YouTube! This should be a great foundation for you to be able to build really robust customizable gun systems for your games that your players will really love!

‍ As always, the full project for this video is available on GitHub!

Hi all, Part 2 of the Series is up! In this video I cover Procedural Recoil / Procedural Bullet Spread with 2 methods - one that you commonly see implemented, based on random values on the X/Y/Z axis, and one based on a texture, to give you a more “predictable random” spray pattern! (link in first post)

Great morning all, Part 3 is up! I cover damaging enemies and arbitrary objects by raising events when they take damage and attach different handlers for death as needed!

Hello Unity developers, Part 4 is now up where I cover how to implement reloading. This seems like a very simple, straightforward concept, but there is some nuance to how the implementation can go!

Hey all, Part 5 is now up where we’ll add ScriptableObject-driven sound effects to our guns. We will play different sounds when for shooting with ammo, shooting out of ammo, last bullet in clip, reloading, and of course, impact sounds handled by the Impact System!

Hi devs! Part 6 is up now where we’ll update the system to also support both Rigidbody projectiles. This enables cool new guns like grenade launchers, rocket launchers…other thing launchers… and gives you the ability to add more realistic bullet physics like bullet drop and drag.

Hi all! Part 7 is up now where we’ll learn how to implement 3 popular options for aiming / shooting bullets, and accurately representing a crosshair!

Great morning all! Part 8 is now up where you can learn how to create a dynamic gun modifier system that enables you to modify attributes of the configuration at runtime!

Hey all, today is Part 9! You can learn how to make explosive and frost rounds (or really any bullet impact effect) using the Modifier System, Impact System, and Damage System we’ve implemented already!

In this week’s video (Part 10!), you can learn how to make an Attachment System in Unity for your guns, like what you see in games like Battlefield and Call of Duty!

This week’s video is a very commonly requested topic - how to have gun pick-ups in game! Check it out in Part 11!

Part 12 and Part 13 are now up which include cool things like Aiming with IK + Animation Rigging, and Bullet Penetration!