Modules
A Module is an object that can be mounted or unmounted on a vehicle's Module Mounts to modify its capabilities.
Examples of modules could be:
Weapons
Shield Generators
Powerplants
Hull 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:
Create a new game object.
Add a Module component.
Customize the settings in the inspector.
You can add any other components you need for that specific module, and then create a prefab from it by dragging it into the Project tab.
Module Information
The Label and Sprites lists enable you to easily add different labels and icons for a module and access them by index. This means you can show different labels and different icons, depending on where on the UI it's being shown - for example you might have one icon for the loadout menu and another for the HUD.
Module Types
To set the type of a module, 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:
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
Was this helpful?