The Weapon System
George LeMaster - 03/24/2023
Obviously, you can’t have a shooter without weapons. Hard coding a weapon is simple enough, the challenge here is figuring out a good, streamlined, modular way to implement an expandable, customizable multi weapon system. The solution? Scriptable Objects.
Scriptable Objects behave a lot like classes, you can create instances of them and store data within them. The big buff for SOs is that you can save them as essentially prefabs, end edit them within the Unity editor. This makes them ideal for items that call on a lot of other assets in your project, like weapon sound effects of models, in this case.
The way the code takes this and makes it usable weapons is quite simple, at least in theory. Just create a reference to a scriptable object of the type you want to use, and set that equal to your desired object, when you want it. From there all your data is ready to be used an manipulated. For example, each weapon SO has a GameObject member that stores the in game graphics for the guns. After you set the objects up, just spawn and despawn these graphics as needed when swapping weapons. Nice and modular, so whoever we add a new weapon to the game, you can just make a new Scriptable Object and hook up its info. It’s so easy, any member of the team could do it, not just the person who wrote the system!
Get 731
731
Status | In development |
Author | OctothorpeFSU |
Genre | Shooter |
Tags | Horror, Singleplayer |
Languages | English |
More posts
- Cutscene Fixes, player breakable glass and Knife SparksJun 23, 2023
- managers, props, and hazardsJun 22, 2023
- Cutscenes, Breakable Glass and Shooting FixesJun 17, 2023
- menus, sound, and notesJun 16, 2023
- Managers/HUD/particle/and splash screen updateJun 09, 2023
- Amaterasu and Map UpdatesJun 02, 2023
- crosshair colors and hit marker added plus two new notesJun 02, 2023
- Enemy and Map Menu UpdatesMay 27, 2023
- hazard update, splash screen, objectives, and modelsMay 26, 2023
- Expanding the EnvironmentMay 23, 2023
Leave a comment
Log in with itch.io to leave a comment.