Wiki

Clone wiki

Modular Vehicle Vol. 2 / Modular Vehicle Documentation

Modular Vehicle Vol. 2

Documentation

Important Info

  • If you're getting an error that "project names may not contain the following characters: ." during project creation, rename project from "ModularVehicleVol.2" into "ModularVehicleVol2"
  • Support email: air.kelheor@gmail.com

Controls:

First Person Character:

  • Jump - Space Bar / Gamepad Face Button Bottom
  • Run - Left Shift / Gamepad Left Thumbstick Button
  • Use - E / Gamepad Face Button Top
  • Change Camera - F / Gamepad Right Thumbstick Button
  • Forward - W / S / Up / Down / Gamepad Left Thumbstick Y-Axis
  • Right - A / D / Gamepad Left Thumbstick X-Axis
  • Turn - Mouse X
  • Turn Rate - Left / Right / Gamepad Right Thumbstick X-Axis
  • Look Up - Mouse Y
  • Look Up Rate - Gamepad Right Thumbstick Y-Axis
  • Field Of View - V

Vehicle:

  • Handbrake - Spacebar / Gamepad Left Trigger
  • Fire - Left Mouse Button / Gamepad Right Trigger
  • Secondary Fire - Right Mouse Button / Gamepad Face Button Right
  • Continuous Fire - Left Mouse Button / Gamepad Right Trigger Axis
  • Use - E / Gamepad Face Button Top
  • Respawn Car - N
  • Activate Main Module - H / Gamepad D-pad Up
  • Possess Main Module - G / Gamepad Face Button Left
  • Activate Stoppers - F / Gamepad D-pad Down
  • Toggle Headlight - B / Gamepad Right Thumbstick Button
  • Select Next Weapon - Right bracket / Gamepad D-pad Right
  • Select Previous Weapon - Left bracket / Gamepad D-pad Left
  • Slow Motion - Z
  • Pause Menu - Escape / Y / Gamepad Special Right
  • Toggle Free Camera - C
  • Activate Jumpers - M
  • Activate Nitro - Left Shift / Gamepad Left Thumbstick Button
  • Forward - W / S / Up / Down / Gamepad Left Thumbstick Y-Axis
  • Forward Rate - Gamepad Right Trigger Axis
  • Right - A / D / Gamepad Left Thumbstick X-Axis
  • Camera Yaw - Mouse X
  • Camera Yaw Rate - Gamepad Right Thumbstick X-Axis
  • Camera Pitch - Mouse Y
  • Camera Pitch Rate - Gamepad Right Thumbstick Y-Axis
  • Camera Zoom - Mouse Wheel Axis / Gamepad Left/Right Shoulder

How to add new module

  • Import required meshes and baked textures
  • Add new module in DT_ModuleClassessList data table (use Row Id as a Module Id later)
  • Duplicate one of the modules blueprints, which fits best for the new module, replace the mesh, define initial parameters like ModuleMaterialData or ModuleData
  • Fill Incompatible Module Id/Sets for other modules, which is incompatible with a new module
  • Set fallback modules if your module is removable
  • If you added chassis mesh, don't forget to make proper physical asset and animation blueprint. Look for existing chassis examples to learn how to properly setup them.
  • You also might need to update DT_VehiclePreDefinedConfigurationsList data table.

How to add new module type

  • Add new module type in EModuleTypes enum
  • Add new module type in MOD_RemovableModules Map in BP_Main_Customization_HUD blueprint (change latest item to new module type, then add chassis as last item). If module can be removed, set checkbox to true. If it's a socket attachable module (like weapons or accessories), set checkbox to false.
  • If module can be attached to sockets, add it into MOD_SocketAttachableModuleTypes Map in BP_Main_Customization_HUD blueprint
  • If it's an internal module without mesh, add it to MAT_UneditableModuleTypes Map in BP_Main_Customization_HUD blueprint
  • Add your module type into VehicleModulesData and Modules variables in BP_ModularVehicle_Base, if this module should be mandatory
  • You also might need to update DT_VehiclePreDefinedConfigurationsList data table.
  • If you have INVALID KEY errors in BP_ModularVehicle_Base, set those keys to Chassis (or Cabin in SetCharacterVisibility method)

How to add new vehicle skin

  • Create a new material, similar to M_Vehicle_Master or duplicate it and add required features or make a material instance of M_Vehicle_Master (look for examples in Materials/Skins folder)
  • Add new skin in DT_MaterialDataList data table, set material name property and configure layer prefixes and editable parameters (or leave everything as is, if it fits you)

How to add new decals

  • Import decal textures and create material instance from M_Decal_Master material
  • Add decal info in DT_ModuleDecalsList data table
  • You may also want to add new decal socket into your skeletal mesh and add it definition into ModuleData structure -> Decal Sockets array in module blueprint.

How to add new module stat

  • Add new module stat in ModuleStats structure
  • If needed, add support for new module stat in "Apply Modules Stats" event in BP_ModularVehicle_Base
  • If needed, use new module stat in required modules
  • Set initial values for new module stat in modules blueprints
  • Update BP_ModuleInfoWidget blueprint to show new parameter in module info widget.

How to add vehicle with pre-defined configuration on the level

  • Place BP_ModularVehicle_Base actor on your level
  • Set Vehicle Pre Defined Configuration variable for an actor to the desired row id in DT_VehiclePreDefinedConfigurationsList data table
  • Set vehicle id to other than player's vehicle id
  • Set IsLoadVehicleDataEnabled to false
  • Set UsePreDefinedVehicleConfiguration to true
  • You also can set UsePreDefinedVehicleConfiguration to false and manually set required modules to load in Vehicle Modules Data per actor

How to load vehicle data in UE4 Editor (before launching game)

You can load vehicle data via construction script by setting InitInConstructionScript to true. This could be useful if you want, for example, to setup lights in the scene. But if your vehicle initialized in this way, you can't use it in runtime due to specifics of loading actors dynamically or you might get editor crash. That's why such a vehicle will be deleted immediately after the game starts.

Disable InitInConstructionScript before:

  • Launching game in the editor
  • Changing level in the editor
  • Moving vehicle in the editor

Otherwise, your vehicle transform may be changed to (0.0.0)

Material Layers in Substance Painter:

Custom channels for mesh with 1 Mask + RGBAO:

  • U0 - Rubber
  • U1 - Steel
  • U2 - Black Metal
  • U3 - Grime
  • U4 - Scratch
  • U5 - Dust

Custom channels for mesh with RGBAO map only:

  • U0 - Grime
  • U1 - Scratch
  • U2 - Dust

Channel type: L8

RGBAO Map:

  • R: Grime
  • G: Scratch
  • B: Dust
  • AO: Ambient Occlusion Map

To speed up texturing process of new modules, you can use Substance Painter master materials from here: https://drive.google.com/drive/folders/1ubFUudIxBloodga1h3T5QmSlayaHojiJ
Copy those materials into Allegorithmic\Substance Painter\shelf\smart-materials folder or add them inside Substance Painter by drag&drop to the viewport.
Use custom channels like in description above. Make separate texture exporters for them.

Data structures description

  • DT_CustomizationEnvironmentsList
    This data table maps environment name (to display in Change Environment scrollbox) onto actual level name to load in customization level.

  • DT_MaterialDataList
    This data table contains data about pre-defined materials, which you can set to the vehicle in "Select Material" tab in customization level.

  • DT_ModuleClassesList
    This data table contains references to all vehicle modules and their IDs as Row Id.

  • DT_TextureMappingList
    This data table contains data about textures, which you can set in Edit Material menu via editable texture parameters.

  • DT_VehiclePreDefinedConfigurationsList
    This data table contains info about vehicle configurations. If you want to quickly load specific vehicle, add it here.

  • ECustomizationModuleActions
    List of actions, which can be executed in "Test Modules" tab in customization level.

  • EModuleTypes
    Module types of a vehicle, from chassis to weapons. Only single item of specific module type can be installed to the vehicle, unless it's a socket-attachable module type, like weapons or accessories.

  • EModuleQuality
    Quality of a module, from common to legendary. You can use auto-multiply module stats feature, depending on module quality by setting "Use Module Quality Stats Multiplier" to true in module settings. You can set multiply coefficients in Get Module Stats method of BP_Master_Module blueprint.

  • EUsageEvents
    List of events, which module can use. You can use ExecuteOnModulesWithCompatibleUsageEvents and ExecuteOnSocketAttachableModulesWithCompatibleUsageEvents macros in BP_ModularVehicle_Base blueprint to select modules with specific events and execute required methods on them.

  • CustomizationEnvironment
    Structure to store data about streamable environments in the customization level.
    Properties:
  • Environment Name - name to display on UI
  • Environment Level Name - name of level asset

  • MaterialData
    Contains data about pre-defined material, which you can apply to the vehicle.
    Properties:
  • Master Material Instance - actual material, which will be applied to the vehicle
  • Material Layer Prefixes - Layer prefixes, which you were used in your material functions inside your master vehicle material for each parameter (like Steel Roughness Intensity, where Steel is a layer prefix).
  • Material Name - actual name to display in UI
  • Editable Scalar Parameters - scalar parameters without layer prefixes inside your material functions, which you can edit via UI
  • Editable Vector Parameters - vector parameters without layer prefixes inside your material functions, which you can edit via UI
  • Editable Texture Parameters - texture parameters without layer prefixes inside your material functions, which you can edit via UI.

  • MaterialParameter
    Contains data about material parameter inside your vehicle material
    Properties:
  • Material Parameter Name - name without layer prefixes inside your material functions (Base Color Tint, for example)
  • Layers Support - which layers will be affected by this parameter (useful for camouflage, for example, so it will affect only single layer)

  • ModuleClass
    Contains reference to module blueprint
    Properties:
  • Module Actor Class - reference to module blueprint

  • ModuleData
    Contains data about vehicle module
    Properties:
  • Module Name - the name of a module to display on UI
  • Module Type - a type of module
  • Module Id - unique id of a module. Should be the same as in DT_ModuleClassesList data table.
  • Module Actor Class - a reference to the module blueprint
  • Module Description - description of a module, which will be shown in module info dialogue
  • Incompatible Module Ids - Ids of modules, which is incompatible with this module
  • Usage Events - on which events this module should react
  • Incompatible Module Sets - the name of module sets, which are incompatible with this module
  • Module Set Name - the name of a module set, which this module belongs (MAZ-543, for example)
  • Linked Module Ids - linked modules also will be activated when this module will be activated
  • Fallback Modules - list of non-removable modules (like chassis or cabin), which will be used as fallback modules, if after installing this module, current set of non-removable modules became incompatible with the current module.
  • Module Sockets - info about module sockets, on which you can attach additional modules, like weapons or accessories.
  • Is Rotatable Module - whether or not this module can rotate (useful for turrets)
  • Module Image - a reference to the image, which will be shown in module info dialogue

  • ModuleMaterialData
    Contains data about vehicle module material
    Properties:
  • Mesh material Indexes - indexes of editable mesh materials. For example, if the mesh has two materials and only one can be editable, set the index of it here (from 0 to N, where N is the number of materials in mesh).
  • Mesh Material Names - Names of materials to display on UI
  • Baked Normals - references to baked normal textures
  • Masks - references to layer mask textures
  • RGBAO Maps - references to RGBAO textures
  • Current Material - current module material
  • Scalar Parameters - stores actual values of scalar parameters
  • Vector Parameters - stores actual values of vector parameters
  • Texture Parameters - stores actual values of texture parameters
  • Persistent Scalar Parameters - stores values of scalar parameters, which can't be changed via the customization system
  • Persistent Vector Parameters - stores values of vector parameters, which can't be changed via the customization system
  • Persistent Texture Parameters - stores values of texture parameters, which can't be changed via the customization system

  • ModuleSocket
    Contains data about module socket
    Properties:
  • Socket Name - name to show on UI
  • Is Rotatable - whether or not module, installed onto this socket, will be able to rotate
  • Module Type - which module type can be installed onto this socket

  • TextureMapping
    Structure to store data about custom textures, which you can apply to the vehicle via editable texture parameters.
    Properties:
  • Texture - actual texture to use
  • Texture Name - texture name to show on UI
  • Material Parameter Name - to which parameter this texture should be applied

  • VehicleModulesData
    Contains data about vehicle configuration.
    Properties:
  • Modules - list of vehicle modules to use
  • SocketAttachableModules - modules list, which can be attached to certain sockets of other modules
  • Configuration name - name to show on UI

Modeling workflow for new modules

In this tip, I want to describe my workflow of making vehicles for this project. I hope it It would be helpful for those people, who would want to add new models to the existing project.

  1. Decide what you want to make and gather references. You need all sides of the vehicle, because they are mostly asymmetrical.

  2. Make high poly mesh by using reference images. I'm using Blender. Mostly I'm using the following modifiers: mirror, bevel, subdiv, triangulate, array, boolean, sometimes solidify and wireframe.

  3. When high poly is ready, it's time to clean everything. Start from checking and applying Scale/Rotation.

  4. Then you need to check your modifiers: Make sure that bevel has 4 segments to prevent issues with materials. I'm using Angle or Weigh Limit Mode. Sometimes it's useful to use Clamp Overlap or set bevel weighs manually (I'm using HOps, so most of the weights are set automatically). Make sure that your mirror modifier doesn't have Bisect or Flip U/V checkboxes selected. One Flip U checked and you're risking to redo a lot of o work due to UV overlapping after export, so check carefully. Make sure that your meshes have triangulate modifier with Keep Normals on. It helps in a situation when you don't have a good topology and don't want any issues with UV later. If you're using subdiv, 2 subdivisions are enough for baking. Apply boolean or solidify modifiers if you didn't do this already. If you have linked duplicates, which exists in multiple collections, make sure execute "Make single user" command with Object Data checkbox selected, so each collection have duplicates, related to their own collection and they not shared between collections.

  5. Apply materials to your meshes. If you have HOps, you can select multiple objects, press Alt+M and apply a material to all selected objects.

  6. Make UV for your meshes. Use Shift+L hotkey to select all objects with the same material to pack UV. For cylinders do UV manually, for box-like meshes Smart Unwrap mostly is enough. Apply Average Island Scale before packing your UV. Don't forget to apply solidify modifier before doing UV.

  7. Create a rig for your meshes: For armature set rotation X to -90 and scale to 0.01 for UE4 A vehicle for UE4 should be placed in X forward axis Use 3D cursor and Shift-S hotkey to place bones in the exact location. Use Ctrl+P -> With Empty Groups to bound meshes to an armature Set vertex groups for your meshes. Make sure that everything works fine in Pose mode

  8. Save everything and exit Blender. Then copy your .blend file and rename postfix from High Poly to Game Ready. Open a new file in Blender.

  9. For each mesh remove unnecessary (for low poly model) meshes, remove bevel and subdiv modifiers. Rename collection names postfix from High Poly to Game Ready.

  10. Save everything again and exit Blender. Then copy your .blend file and rename postfix from Game Ready to Bake. Open a new file in Blender.

  11. Append high poly collections into your bake file. Unhide all collections except current high poly and game ready for the selected model. Then by selecting similar meshes and moving them, explode model parts to get better baking results.

  12. Export your bake meshes (2 meshes for each model - high poly and game ready for baking) and import them into Marmoset Toolbag.

  13. Add baker, Set Multiple Texture Sets checkbox, select required materials, select all maps except Material ID, Set Fix Mirrored Tangents checkbox, Change output name, set samples to 16x, for Normal maps set Flip Y checkbox if you're using UE4, set High Poly and Low Poly meshes, hide High Poly. Make test bake with normal map only to see if everything is ok. Then bake all other maps. Paint Scew/Offset if needed.

  14. Open Game Ready .blend file and export your game ready models with armatures (you can also export the combined mesh, which contains all models, to simplify the texturing process). Open Substance Painter 2, import your mesh and baked textures. Apply baked textures. Add custom channels (L8). Apply masks and export normal maps + masks + RGBAO maps (packed with Grime/Scratch/Dust/AO masks).

  15. Import your game ready meshes and created textures into UE4. For masks texture set compression settings to masks. Make Physics Assets for meshes. Apply non-customizable materials (like mirror material) to the meshes. Create blueprints for new modules.

  16. Test that everything works and looks fine.

Ground trails

Built-in landscape material supports ground trails for certain layers (like snow). To use this feature, you need to add BP_GroundSceneCapture actor to your level and select the capture method.

If UseGroundTrailsCaptureByAffectorMethod set to true, then wheel trails will be captured with particles. This method is good for the vehicle, because if you will move on a long distance and return back, old trails will be visible until particles are alive. If you use this method, you should place the capture actor above your level ground.

If UseGroundTrailsCaptureByAffectorMethod set to false, the depth check method will be used. This method will allow you to capture trails from any mesh, which have Render Custom Depth Pass set to true. The disadvantage of this method is that if you will ride far from any initial location and return back, trails might be partially removed, which might not look good for you. Those trails won't be removed if you won't leave far away from them. If you use this method, you should place capture actor below your level ground.

Keep in mind that this feature might be expensive in terms of performance.

AI Types

This project contains 3 types of AI: vehicle, aircraft, and character. You can use them as a start point and extend them to your own needs. You can find them in Blueprints/AI folder. For vehicle and character AI you need to place Nav Mesh Bounds volume on your level. Vehicle AI can use two navigation methods: follow a certain target and move across waypoints (the first waypoint will be selected by random from available). Each AI type has property, which allows you to make them enemies for the player, so they will attack them. Non-enemy AI will also attack enemy AI and vice versa. AI behavior can be controlled via behavior trees.

Migrate project

Useful links on how to migrate this project's content into other projects:
https://wiki.unrealengine.com/Migrate_content_between_projects
https://docs.unrealengine.com/en-US/Engine/Content/Browser/UserGuide/Migrate/index.html

Make sure to look into config files in the Config folder and compare them with your own project configs. Add those parameters (like input mapping, rendering/collision/physics settings, ), which your project doesn't have (unless you really don't need them and you know what are you doing).

Useful tips:

If you changed or added a new module or material parameters and you can't see them, try to disable loading of vehicle data in by temporary set IsLoadVehicleDataEnabled variable to false, then saving the game by opening Showcase level from Customization level for example. Also, you may want to look at DT_MaterialParametersList data table - if you added new values MaterialParameters structure, you may also need to update your data table. You may also need to update ModuleMaterialData variable (default values) in BP_MasterModule.

Weapon Socket names should follow certain naming convention: <Module Type> <Socket Attachable Module Type> Socket X. For example: Cabin Weapons Socket 1

In DT_VehiclePreDefinedConfigurationsList first module should be Chassis. But due to a bug in UE4 you need to first add it to the latest element of the array, then change the first element to Weapon, last to Main Module, then first to Chassis.

It's recommended to set row id in DT_ModuleClassesList to module ID to look for IDs in one place when you set compatibility settings.

If the module has incompatible with other modules Module Set Name, then this module won't be added to the modules list. If the module is incompatible with other modules but have compatible Module Set, then it will be added to the modules list, but if you will try to select it, you will get a warning about module incompatibility. If you still select this module, it will remove other incompatible modules. If an incompatible module is a non-removable module, the fallback module will be added instead of the removed module.

If you think that some of the textures have too high resolution, you can change it in texture settings (Compression -> Maximum Texture Size - set it to 512, 1024, 2048, etc).

You probably need to fine-tune min and max height for Aircraft AI, which depends on your level height.

The main source of collision for a vehicle is a physics asset of chassis mesh. Don't try to enable physics/add collision for any other modules or your vehicle will jump to the sky. UE4 can't weld simulated bodies for skeletal meshes and there some other issues with the vehicle, which prevents to add normal per-module collision support. The only way to add additional collisions is via collision primitives in modules blueprint. But you must check that those new collisions won't be overlapped by chassis collisions, or your vehicle also will jump to the sky at begin play. Look into BP_Support_Module_01 blueprint to learn workaround on how to add additional collisions for your vehicle. Keep in mind that it works in a way that additional collider collides with chassis collision and stops it. So if custom collider will be moved in a way that it won't collide with chassis, nothing will happen, so keep that in mind and try to not make modules taller than chassis collision if possible.

Don't forget to copy settings from Project Settings -> Physics (Physical surfaces) and Collision (Collision presets and channels for projectile).

If you have triggers, which runs on pawns, for example, keep in mind that the vehicle contains multiple pawns (each module is a pawn because it can be possessed), so your triggers might be executed multiple times. In this case, it's better to check for BP_VehicleInterface rather than pawn.

Recommended engine scalability settings: Epic

If usable actors not highlighted, make sure that you added PPI_OutlineColored material into your post process volume.

Updated