Modules

A Module is an object that can be added or removed from a vehicle, in the loadout screen or during gameplay, to add or remove functionality.

Examples of modules could be:

  • Weapons

  • Shield Generators

  • Powerplants

  • Armor Upgrades

  • etc

The following sections cover the fundamentals of modules, but creating specific types of modules will be covered in sections dedicated to the functionality that the module is part of.

Creating a Module

To create a new module, simply add a Module component to a game object and customize the settings in the inspector.

Module Information

To make it easy for you to create and display relevant module information, several inspector fields have been added.

The Label, Description and Sprites list fields enable you to easily create information about the module to be displayed in a menu or UI.

The ID field in the inspector of the Module component provides a way to identify and access a specific module at a module mount when several modules may have the same Module Type and Label. It can be used however you wish.

Module Types

Module types enable you to easily categorize modules, for example to only allow certain kinds of modules on a particular vehicle.

Module Types are scriptable objects that are stored in your Assets folder.

To create a new Module Type, right click in the Project tab, select Create > VSX > Module Type, and rename the created object.

To make a module a specific Module Type, drag the Module Type you created into the 'Module Type' field in the inspector of the Module component.

Attachment Items

Sometimes you may have a single module with multiple objects that are attached independently to the vehicle. For example, a twin weapon where each weapon must be mounted on opposite sides of the vehicle.

To make this easy to set up, add each weapon object to the Attachment Items list in the inspector of the Module component. Then go to the Module Mount on each vehicle where the module might be loaded, and add elements to the Attachment Points list that represent where the weapon objects must go when the module is mounted on the vehicle.

Each element in the Attachment Items list on the Module will go to the position/rotation of the corresponding element in the Attachment Points list on the Module Mount.

Activating/Deactivating

You can activate or deactivate a module in code like so:

// Activate the module
myModule.SetActivation(true);

// Deactivate the module
myModule.SetActivation(false);

// Check if the module is activated
if (myModule.IsActivated)
{
    // Some code
}

By default, the module activation does nothing, but you can add your own functions to the events in the inspector to be called when the module is activated or deactivated.

Root Transform Users

Sometimes a component on the module will require a reference to the root transform of the vehicle that it is attached to - for example, a weapon might need to ignore damage to the vehicle that fired it.

If you have a component of your own that requires the root transform of the vehicle, make sure the component class implements the IRootTransformUser interface and the value will automatically be passed to it.

Module Events

The Module component comes with many events you can add functions to that will be called when the event occurs, including:

  • On Mounted - called when the module is mounted at a module mount

  • On Unmounted - called when the module is unmounted from module mount

  • On Activated - called when the module is activated after being inactive

  • On Deactivated - called when the module is deactivated after being active

  • On Owner By Player - called when the module is mounted at a module mount of a vehicle occupied by a Player Game Agent

  • On Owner By AI - called when the module is mounted at a module mount of a vehicle occupied by an AI Game Agent

  • On No Owner - called when the module is unmounted from a vehicle

All these events are called from functions that you can override by extending the Module base class.

Last updated