Module Mounts

Module Mounts are places on a vehicle where modules are mounted onto a vehicle.

Any number of modules can be added to a module mount, but only one may be mounted at any time. This means that you can add multiple modules and switch between them during game play.

Creating A Module Mount

To create a module mount on a vehicle, add a new game object as a child of the vehicle, rename it to something relevant, and add a Module Mount component. Set the local position and rotation according to how you would like the module to be oriented when it is added to the vehicle.

Module Mount Information

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

The Label field enables you to display a label for the module mount in a menu or UI.

The ID field provides a way to identify and access a specific module mount on the vehicle, for example by an input script. It can be used however you wish.

The Sorting Index field provides a way to index module mounts so that they are displayed in a specific order, for example in the loadout menu.

Specifying Mountable Types

Let's say you want to add a module mount to a vehicle that can only be used to load gun weapons.

  1. Create a Module Type for gun weapons.

  2. Check the Specify Mountable Types checkbox in the inspector of the Module Mount component.

  3. Drag the Module Type you created in step 1 into the Mountable Types list in the inspector of the Module Mount component.

Adding Existing Modules

Let's say you already added modules to the hierarchy of the module mount. If you want these to be added to the module mount at runtime, check the Load Existing Child Modules checkbox in the inspector of the Module Mount component.

Adding Module Prefabs

Let's say you have some module prefabs that you've created, and you want them all to be added to a module mount.

Drag all the prefabs to the Default Module Prefabs list in the inspector of the Module Mount component, and they will be created there when the scene starts.

Checking Module Compatibility

To check if a module is compatible with a module mount, use the following code:

// Check if a module is compatible with the module mount
if (myModuleMount.IsCompatible(someModule))
{
    // Some code
}

Adding/Removing Modules

To add or remove modules during game play, use the following code:

// Add a module
myModuleMount.AddModule(someModule);

// Remove a module
myModuleMount.RemoveModule(someModule);

// Remove all modules from the module mount
myModuleMount.RemoveAllModules();

Accessing Added Modules

To access the modules added to a module mount, you can access the Modules list from a reference to the Module Mount component with the following code:

// Get a list of modules at a module mount
List<Module> modules = myModuleMount.Modules;

Mounting/Unmounting Modules

To mount the first module that is added to the module mount when the scene starts, check the Mount First Available Module At Start checkbox in the inspector of the Module Mount component.

To mount or unmount modules during game play, use the following code:

// Mount a module by direct module reference
myModuleMount.MountModule(someModule);

// Mount a module by the module's ID (string)
myModuleMount.MountModule(someModuleID);

// Mount a module by its index in the Modules list (int)
myModuleMount.MountModule(someIndex);

// Mount the next module
myModuleMount.Cycle(true);

// Mount the previous module
myModuleMount.Cycle(false);

// Unmount the currently mounted module
myModuleMount.UnmountActiveModule();

Accessing The Currently Mounted Module

To access the module that is currently mounted at a module mount, use the following code:

// Get the currently loaded module - if none loaded, the result will be null
Module loadedModule = myModuleMount.MountedModule();

Last updated