Skip to content

Implementation

Timm edited this page Aug 23, 2024 · 16 revisions

You can implement demo functionality by following the steps below.

Modularity

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

Weapon

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.

image

Weapon Registry

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 );

image

Weapon Settings

The base offers a few settings to easily customize, your scene is required to have a WeaponSettings component.

image

Player

  • 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

HUD

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.

image

Clone this wiki locally