-
Notifications
You must be signed in to change notification settings - Fork 28
Implementation
You can implement demo functionality by following the steps below.
Almost all base parts are separable (swb_shared is always needed).
- Weapons only:
swb_base
+swb_shared
- Weapons with player controller:
swb_base
+swb_player
+swb_shared
- Weapons with player and demo HUD:
swb_base
+swb_player
+swb_hud
+swb_shared
To create a new weapon simply create a new gameobject and attach the Weapon
component, after you are done editing save this as a prefab.
Before you can use weapons you need to register them, create a new gameobject in the scene root and attach the WeaponRegistery
component.
Then add the created weapon gameobject to the Weapon Prefabs
property.
Once setup you can now use the following code to access the weapon to check its properties or clone it.
var weaponRegistery = Scene.Components.GetInChildren<WeaponRegistry>();
var weaponGO = weaponRegistery.Get( className );
var weapon = weaponGO.Components.Get<Weapon>( true );
The base offers a few settings to easily customize, your scene is required to have a WeaponSettings component.
- If you want to base your player on the demo player class with all animators and controllers setup then extend your player class with the
SWB.Player.PlayerBase
class.MyPlayer : PlayerBase
- If you want to make your own player base compatible then you only need to implement the
SWB.Shared.IPlayerBase
interface.MyPlayer : IPlayerBase
If you want the demo HUD (scoreboard, inventory, killfeed) you'll need to add it to your player root panel, the provided PlayerBase does this with a property.