Module Mounts
Last updated
Was this helpful?
Last updated
Was this helpful?
Module Mounts are places on a vehicle where modules are mounted onto a vehicle. A vehicle can have any number of Module Mounts.
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 to a single mount, and cycle between them during game play.
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.
Let's say you want to add a module mount to a vehicle that can only be used to load gun weapons.
Create a for gun weapons.
Drag the Module Type you created in step 1 into the Mountable Types list in the inspector of the Module Mount component.
Make sure all the gun weapon modules have their 'Module Type' set to the Module Type you created, in the inspector of their Module components.
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.
Go to the Player and add a PlayerInput_InputSystem_ModuleMountControls component in its hierarchy.
Go to the Module Mount you want to control and make sure its ID is the same as the 'Module Mount ID' value in the inspector of the PlayerInput_InputSystem_ModuleMountControls component from step 1.
Now play the game. You can cycle forward and back through the modules at that module mount, when the player is controlling that vehicle. Open the General Input System asset to see/modify the inputs.
Alternatively, if you'd like to cycle modules at a module mount in our own code, use this code:
To check if a module is compatible with a module mount in code, use the following code:
A module is added to a module mount when it is placed there and ready to be mounted. But a module that is added still needs to be mounted - remember that while many modules can be added to a module mount, only one of them can be mounted.
To add or remove modules from a module mount during game play, use the following code:
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:
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:
To access the module that is currently mounted at a module mount, use the following code: