Create a dynamic gun modifier system to enable runtime property changes of your guns! We'll also cover how to prevent ScriptableObjects from persisting these changes in the editor.
In this video we'll set up a modifier system and implement 2 popular modifiers:
1. Damage Modifier, which allows us to raise or lower the damage of any gun when it's applied.
2. Vector3Modifier, which allows us to apply a percentage offset to any Vector3, such as the Bullet Spread amount.
💸 Ongoing sales 💸
⚫ Epic Royalty Free Music Collection Humble Bundle: https://www.humblebundle.com/software/epic-royaltyfree-music-collection-software?partner=llamasoftware&charity=2280172
⚫ Unity RPG Course from GameDev.tv: https://www.humblebundle.com/software/learn-to-create-rpg-games-in-unity-software?partner=llamasoftware&charity=2280172
⚫ Aquarius Max Publisher Sale! 50% OFF all Aquarius Max's Assets! https://assetstore.unity.com/publisher-sale?aid=1101l9QvC
⚫ FREE Ultimate Medieval Constructor Asset with Promo Code: AQUARIUS https://assetstore.unity.com/packages/3d/environments/fantasy/ultimate-medieval-constructor-97279?aid=1101l9QvC
⚫ See all active asset sales on the Asset Store: https://assetstore.unity.com/?on_sale=true&orderBy=0&rows=96&clickref=1100lwtudvMJ&utm_source=partnerize&utm_medium=affiliate&utm_campaign=unity_affiliate&aid=1101l9QvC
⚫ Save 25% off your first Asset Store Order: https://prf.hn/click/camref:1101l9QvC/creativeref:1011l78340
⚫ Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sale=true&orderBy=1&aid=1101l9QvC
👨💻 As always, all code from this video is available on GitHub: https://github.com/llamacademy/scriptable-object-based-guns
📚 Resources:
⚫ Reflection: https://learn.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/reflection
⚫ Type Class: https://learn.microsoft.com/en-us/dotnet/api/system.type?view=net-7.0
⚫ FieldInfo: https://learn.microsoft.com/en-us/dotnet/api/system.reflection.fieldinfo?view=net-7.0
⚫ ICloneable: https://learn.microsoft.com/en-us/dotnet/api/system.icloneable?view=net-7.0
❤ Believe in LlamAcademy's mission and have received value from the videos? Become a Patreon Supporter or YouTube Member:
⚫ Patreon: https://www.patreon.com/llamacademy
⚫ YouTube Member: https://www.youtube.com/channel/UCnWm6pMD38R1E2vCAByGb6w/join or click the Join button on any video
📱 Let's stay connected
YouTube: https://youtube.com/c/LlamAcademy
Patreon: https://www.patreon.com/llamacademy
Facebook: https://facebook.com/LlamAcademyOfficial
Twitter: https://twitter.com/TheLlamAcademy
TikTok: https://tiktok.com/@LlamAcademy
Instagram: https://instagram.com/LlamAcademy
----
Most tutorials come from knowledge gained making https://survival.llama.software Llama Survival - a top-down zombie survival shooter for Android and iOS.
I also have some Unity Assets: https://assetstore.unity.com/publishers/22409?_aid=1101l9QvC
Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.
#unitytutorial #tutorialtuesday #gamedev #tutorial #unity #llamacademy #gamedevelopment
Chapters:
00:00 Topic Introduction
00:41 Concepts & What to Expect
02:35 Cloning ScriptableObjects to Prevent Runtime Modification - GunScriptableObject.cs
03:00 Cloning ScriptableObjects to Prevent Runtime Modification - DamageConfigScriptableObject.cs
03:25 Cloning ShootConfigScriptableObject.cs
03:46 Reusable way to copy all values on a ScriptableObject
05:30 Set up cloning on the rest of the ScriptableObjects using Reflection
06:17 Clone GunScriptableObject.cs - This one is different!
07:23 Modifiers setup
07:54 Base IModifier - the AbstractValueModifier.cs
11:37 Throw a Custom Exception
11:58 Finish AbstractValueModifier
13:06 Create our first Modifier - The DamageModifier.cs
14:59 Another, more generic example - Vector3Modifier.cs
15:48 Applying modifiers - GunModifierApplier.cs
16:41 Clone the ActiveGun in PlayerGunSelector.cs
17:05 Set up and Demo
17:58 Closing Thoughts & Support LlamAcademy