Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Tutorial - Make a ScriptableObject-Based Gun System from Scratch

Discussion in 'Community Learning & Teaching' started by ChrisKurhan, Oct 11, 2022.

  1. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    240
    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:
    1. Gun Scriptable Object - holds the model, does the shooting
    2. Shoot Config Scriptable Object - holds how the gun will shoot
    3. Bullet Trail Config Scriptable Object - holds how the gun trail will appear

    Here's the Series Playlist:
    1. Part 1 - Shooting with a Gun Scriptable Object, Shoot Config, & Bullet Trail Config
    2. Part 2 - Procedural Recoil & Bullet Spread
    3. Part 3 - Deal Damage to Enemies and Objects with Guns
    4. Part 4 - Animation-driven Reloading
    5. Part 5 - Sound Effects

    I'm going to cover other topics like:
    1. Reloading
    2. Complex Bullet Spread
    3. Fire Modes (burst/automatic/single shot)
    4. Sounds
    5. Projectile-based guns
    6. Recoil
    7. Damaging enemies
    8. Sound Effects
    9. Modifiers
    10. Attachments
    11. Skins
    12. And more!

    As always, the full project for this video is available on GitHub!
     
    Last edited: Jan 3, 2023
  2. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    240
    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)
     
  3. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    240
    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!
     
  4. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    240
    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!
     
  5. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    240
    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!