Procedural Recoil and Bullet Spread | Gun Series 2




Published: 01 Nov 2022

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!


๐Ÿ‘จโ€๐Ÿ’ป As always, all code from this video is available on GitHub: https://github.com/llamacademy/scriptable-object-based-guns


๐Ÿท๏ธSave 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?section=personal&billing=yearly


๐Ÿ“š Resources:

โšซ Texture2D: https://docs.unity3d.com/ScriptReference/Texture2D.html

โšซ Texture2D.GetPixels: https://docs.unity3d.com/ScriptReference/Texture2D.GetPixels.html

โšซ Texture2D.GetRawTextureData: https://docs.unity3d.com/ScriptReference/Texture2D.GetRawTextureData.html

โšซ More in-depth explanations on the sampling of texture data here: https://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: https://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!


๐Ÿงก Believe in LlamAcademy's mission and have received value from the videos? Here's how you can show your support:

๐ŸŒŸ Patreon: https://www.patreon.com/llamacademy

๐ŸŒŸ YouTube Member: https://www.youtube.com/channel/UCnWm6pMD38R1E2vCAByGb6w/join or click the Join button on any video

๐Ÿ“š Take my Unity ShaderGraph Course:

https://www.gamedev.tv/p/unity-shader-graph?affcode=45216_kuvg0bp7

๐Ÿ‘• Get yourself some LlamAcademy merch: https://llamacademy.myspreadshop.com/

๐Ÿ’ธ Use my Affiliate Link for Humble Bundles https://humblebundleinc.sjv.io/9g4ak4

๐Ÿ’ธ Publisher Sale! 50% OFF an entire publisher's Assets! Publisher changes weekly! https://assetstore.unity.com/publisher-sale?aid=1101l9QvC (affiliate)

๐Ÿ’ธ Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sale=true&orderBy=1&aid=1101l9QvC (affiliate)


Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.


Connect on Social Media

Some links may be affiliate links, which at no additional cost to you, gives LlamAcademy a small portion of the purchase.