Mighty Gun Extras
This package adds some extra functionality on top of the standard Gun package and doesn’t require any code modification.
- Limited ammo
This is the key step that should be performed regardless of what features you want to add to your gun.
- Drag and drop “PlayerGunExtras” template into your Player template
- Drag and drop “GunExtras” template into your Gun template
- Drag and drop “PlayerGunRecoil” template into your Player template
- Drag and drop “GunRecoil” template into your Gun template
- Adjust recoil values in GunRecoil:
recoilis a Vector2D property where x is a max horizontal offset of the cursor (this offset will be randomized) and y is a vertical offset (this value is applied as it is).
ironSightRecoilMultiplierproperty allows you to specify the recoil multiplier that will be applied while iron sight is active (could be useful for recoil reduction).
- Drag and drop “PlayerGunScope” template into your Player template
- Drag and drop “GunScope” template into your Gun template
- Adjust scope values:
shakeMultiplierproperties are allowing you to control the contribution of the player breath and handshaking on the scope movement.
To increase the zoom of the Scope you need to modify the “fov” property of the
ironSightItemScript is usually attached to the gun entity (the lower the fov value, the higher the zoom is).
- Drag and drop “PlayerAmmoHolder” template into your Player template
- Open the “PlayerAmmoHolder” and drag and drop “PlayerAmmoProperties” inside
- Configure the “PlayerAmmoProperties”:
nameproperty is used to identify the ammo (example: “6mm”, “.357MAG”, “Rocket”, “Potato”, “Dead cat”)
initialAmmoproperty defines the initial amount of ammo of that type players hold. When set to -1 player starts with the maximum allowed ammo.
maxAmmoproperty controls the maximum amount of ammo of that type players are allowed to hold. When set to -1 the ammo is infinite
iconproperty allows you to specify the URL of the icon that will be shown next to the ammo counter in the widget.
- Repeat steps 2 and 3 for each ammo type you want to have in your game
- Drag and Drop “GunAmmo” template into your Gun template
- Specify the appropriate ammo name within “GunAmmo” (It should match the previously defined ammo types)
The package also includes the “AmmoPickupExample” template. (You need to specify the ammo type and the amount of ammo it holds within it)
If you want to add ammo to the player through the code you could do it by calling: