Uploaded November 2022 | Updated September 2026, 2 hours ago
Learn how to implement procedural bullet spread and gun recoil ๐ฅ into your game with this ScriptableObject-based gun system (Part 2 of the Gun Series!)
In this Unity Tutorial you'll learn how to implement recoil/bullet spread in 3 ways -
1. No spread - always perfectly accurate
2. "Simple" Spread - the most common way you'll find to implement spread, based on random values in a Vector3 Range
3. Texture-Based Spread - sampling a texture to define a "pattern of randomness" based on some texture data. Using this you can get something like the recoil in popular games such as Counter-Strike.
Bullet spread and Recoil are inseparable topics, because the recoil actually makes the bullet spread happen! Learn how to do both in this tutorial!
๐ถ ALL THINGS LlamAcademy now available at: https://llamacademy.dev/support including latest tutorials, courses, ways to support, and more! Check it out ๐
๐จโ๐ป Get the FULL FREE PROJECT on GitHub: github.com/llamacademy/scriptable-object-based-guns
๐ท๏ธSave 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: jetbrains.com/store/?section=personal&billing=yearly
๐ Resources:
๐ Texture2D: docs.unity3d.com/ScriptReference/Texture2D.html
๐ Texture2D.GetPixels: docs.unity3d.com/ScriptReference/Texture2D.GetPixels.html
๐ Texture2D.GetRawTextureData: docs.unity3d.com/ScriptReference/Texture2D.GetRawTextureData.html
๐ More in-depth explanations on the sampling of texture data here: youtu.be/yqlFrLGeRaQ
In this series you'll learn how to make a configuration-driven gun system with ScriptableObjects that will be able to have:
๐ Hitscan Guns - Covered in Part 1: youtu.be/E-vIMamyORg
๐ Projectile Guns
๐ Simple Bullet Spread - Refined in this video
๐ Complex Bullet Spread - Covered in this Video
๐ Reloading
๐ Attachments
๐ Animated Models
๐ Simple Impact Damage
๐ Damage Effects such as burning, freezing, explosions, etc...
๐ And even more!
Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.
Chapters:
00:00 Topic Introduction - What to Expect
02:15 Important Player Model Change
02:50 BulletSpreadType.cs - Type options for different recoil/bullet spread
03:04 Remove Spread from GunScriptableObject.cs & Add to ShootConfigurationScriptableObject.cs
04:11 Setup Spread Types - ShootConfigurationScriptableObject.cs
05:38 Add More Recoil over time and "Recovery" - ShootConfiguratioNScriptableObject.cs
06:26 Texture-based Recoil - ShootConfigurationScriptableObject.cs
10:26 Become a Supporter! Thank you all!
10:53 Handle "Recoil Time" - GunScriptableObject.cs
14:14 Applying Procedural Recoil & Recovery to the Gun - GunScriptableObject.cs
15:43 PlayerAction.cs - Use GunScriptableObject.Tick instead of Shoot
15:57 Update Model Spawning in GunHolder
16:18 Demo
17:45 Performance Notes on Texture Sampling
Learn how to implement procedural bullet spread and gun recoil ๐ฅ into your game with this ScriptableObject-based gun system (Part 2 of the Gun Series!)
In this Unity Tutorial you'll learn how to implement recoil/bullet spread in 3 ways -
1. No spread - always perfectly accurate
2. "Simple" Spread - the most common way you'll find to implement spread, based on random values in a Vector3 Range
3. Texture-Based Spread - sampling a texture to define a "pattern of randomness" based on some texture data. Using this you can get something like the recoil in popular games such as Counter-Strike.
Bullet spread and Recoil are inseparable topics, because the recoil actually makes the bullet spread happen! Learn how to do both in this tutorial!
๐ถ ALL THINGS LlamAcademy now available at: https://llamacademy.dev/support including latest tutorials, courses, ways to support, and more! Check it out ๐
๐จโ๐ป Get the FULL FREE PROJECT on GitHub: github.com/llamacademy/scriptable-object-based-guns
๐ท๏ธSave 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: jetbrains.com/store/?section=personal&billing=yearly
๐ Resources:
๐ Texture2D: docs.unity3d.com/ScriptReference/Texture2D.html
๐ Texture2D.GetPixels: docs.unity3d.com/ScriptReference/Texture2D.GetPixels.html
๐ Texture2D.GetRawTextureData: docs.unity3d.com/ScriptReference/Texture2D.GetRawTextureData.html
๐ More in-depth explanations on the sampling of texture data here: youtu.be/yqlFrLGeRaQ
In this series you'll learn how to make a configuration-driven gun system with ScriptableObjects that will be able to have:
๐ Hitscan Guns - Covered in Part 1: youtu.be/E-vIMamyORg
๐ Projectile Guns
๐ Simple Bullet Spread - Refined in this video
๐ Complex Bullet Spread - Covered in this Video
๐ Reloading
๐ Attachments
๐ Animated Models
๐ Simple Impact Damage
๐ Damage Effects such as burning, freezing, explosions, etc...
๐ And even more!
Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.
Chapters:
00:00 Topic Introduction - What to Expect
02:15 Important Player Model Change
02:50 BulletSpreadType.cs - Type options for different recoil/bullet spread
03:04 Remove Spread from GunScriptableObject.cs & Add to ShootConfigurationScriptableObject.cs
04:11 Setup Spread Types - ShootConfigurationScriptableObject.cs
05:38 Add More Recoil over time and "Recovery" - ShootConfiguratioNScriptableObject.cs
06:26 Texture-based Recoil - ShootConfigurationScriptableObject.cs
10:26 Become a Supporter! Thank you all!
10:53 Handle "Recoil Time" - GunScriptableObject.cs
14:14 Applying Procedural Recoil & Recovery to the Gun - GunScriptableObject.cs
15:43 PlayerAction.cs - Use GunScriptableObject.Tick instead of Shoot
15:57 Update Model Spawning in GunHolder
16:18 Demo
17:45 Performance Notes on Texture Sampling










