Procedural Recoil and Bullet Spread | Gun Series 2 | Unity Tutorial @LlamAcademy
Procedural Recoil and Bullet Spread | Gun Series 2 | Unity Tutorial  @LlamAcademy
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
Procedural Recoil and Bullet Spread | Gun Series 2 | Unity TutorialHow You Can Find the OffMeshLinks a NavMeshAgent Will Take | AI Series 43 | Unity Tutorial #ShortsAssembly Definitions, Explained | Unity TutorialCreate Cross-Platform IAP Store Page with Unity IAP in 2023 | Unity Tutorial #shortsAnimate Your NavMeshAgents with Root Motion | AI Series Part 42 | Unity Tutorial #ShortsNamespaces in C# by Unity Example | Beginner Unity TutorialOpaque Objects Making It Hard to See? Fade Them Out with the Standard URP Shaders #shortsEvery Physics Overlap Visualized | Unity TutorialJust another day using VSCode to build Unity games...Inheritance and Interfaces for Beginners | Unity C# Basics 6 | Unity TutorialProcedural Mesh & Animation with the Official Unity Spline Package | Unity TutorialRoot Motion NavMeshAgent Animation | AI Series Part 42 | Unity Tutorial
LlamAcademy |

Procedural Recoil and Bullet Spread | Gun Series 2 | Unity Tutorial

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER