Hi, I’m trying to make the game more complex adding different types of weapons for different type of units. Would be necesary to implement a weapon manager or changing the weapon in the different type of units would solve the porblem? If it is, how is the best way to implement that weapon manager?
If your units are not going to be swapping weapons through the course of the game (i.e. a rifleman will always fire a rifle, an archer will always fire a bow, a man in black will always fire a noisy cricket), then it’s probably easiest to equip the weapon into each unit as appropriate and then have a field in your shootAction (or melee action?) with the correct amount of damage and range, as well as the correct projectile prefab.
If you’re looking to swap weapons mid-game, then you’ll need a weapon manager of some sort. My recommendation for this is to use the WeaponConfig setup in the RPG: Core Combat course.
Okay, thanks for the advise. In general all the units that I was thinking for, only use one or two weapons at a time.
If you want to dynamically equip/unequip then yes implement a Weapon system. Could be a simple as something to store a primaryWeapon and secondaryWeapon and keep track of which one is active. When swapping weapons maybe update the Actions on the Unit, if different Weapons have different actions.
For example when swapping from a Shotgun to a Rifle remove the ShotgunShootAction and add a RifleShootAction. Don’t forget to update the Action array on the Unit
Yep, I implemented this sistem and it works perfectly. Thanks for the advise.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.