Weapons are scriptable objects that allow to configure how a weapon looks like, how to hold it, as well as link it to a particular Ammo object.
Ammunition (from now on Ammo) are the other objects used by the Shooter module that allow you to create any kind of weapon. Weapon objects allow you to define how the Character behaves using a certain gun, but Ammo allows to define what happens when shooting it, charging shots, how the aiming is done, etc...
The Weapon asset represents the definition of a specific weapon of your game. From a simple Steel Sword to a Fire spellbound Battle Axe.
Shield assets complement Weapon assets and provide a way to block incoming attacks, as well as determine how much pressure the wielder can withstand.
Melee Clips are the essential part of the Melee module. You can think them as animation clips in steroids, where you can not only define what animation will be played, but also what effects this animation has, when these happen and how this affects the character and enemies behavior.
Weapon
) and add a weapon asset to it. To learn how to extend the inventory, follow this guide: Inventory Custom Entries GetEquip()
accesses the PlayerEquipment
component of the specified gameobject and searches for equipped items of a specified type. In my case, it reads the inventory of my player and searches for equipped items of type Rifles. GetRifleDetails()
gets called when I open the inventory or equip another weapon. weapon
field and now we can get every stat we want. rifleName
, rifleImage
etc. are the variables for the UI elements. GameObject.Find()
. This approach is slower than the above one, but it doesn't have a big impact on performance because we aren't using it all the time. Let's have a look at some examples: GameObject.Find()
searches the hierarchy for a gameobject with a certain name. In the end this is the same as using public TextMeshProUGUI itemName;
and dragging the gameobject with the TextMesh component on it. GetItemDetails()
needs to be called whenever I click on an item. ItemUI
which holds a reference to the item in the database. By using .itemObject
, we get a reference to this item and can now access the weapon values. Finally the stats are written to the UI elements. PlayerShooter
component (for the player) or the CharacterShooter
(for characters). MeleeWeapon
to your item in the item catalogue the same way you add custom entries to it. Drag and drop a melee weapon asset on it to get a reference to this weapon. You can then simply access the melee weapon: CharacterMelee
component and you are good to go: