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!


🔶 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: 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!


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.