Install Support Package and Configure Environment
To customize scenes in your installation of the Unreal® Editor and simulate within these scenes in Simulink®, you must first install and configure the Vehicle Dynamics Blockset™ Interface for Unreal Engine® 4 Projects support package.
Note
These installation instructions apply to R2022a. If you are using a previous release, see the documentation for Other Releases.
Verify Software and Hardware Requirements
Before installing the support package, make sure that your environment meets the minimum software and hardware requirements described in Unreal Engine Simulation Environment Requirements and Limitations.
Install Support Package
To install the Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects support package, follow these steps:
On the MATLAB® Home tab, in the Environment section, select Add-Ons > Get Add-Ons.
In the Add-On Explorer window, search for the Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects support package. Click Install.
Note
You must have write permission for the installation folder.
Configure Environment
The Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects support package includes these components:
An Unreal project,
AutoVrtlEnv.uproject
, and its associated files. The project includes editable versions of the prebuilt 3D scenes that you can select from the Scene description parameter of the Simulation 3D Scene Configuration block. To use this project, you must copy the file to a folder on your local machine.Three plugins,
MathWorkSimulation
,RoadRunnerMaterials
, andMathWorksAutomotiveContent
. These plugins establish the connection between MATLAB and the Unreal Editor and is required for co-simulation. You must copy this plugin to your local installation of the editor.
To copy the project to a local folder and the plugin to your Unreal Editor installation, follow these one-time steps. Use the Code That Configures Scene Configuration (Steps 1–4).
Step | Description |
---|---|
1 | Specify the location of the support package project files and a local folder destination. Note You must have write permission for the local folder destination. |
2 | Specify the location of the Unreal Engine installation, for example |
3 | Copy the |
4 | Copy the support package folder that contains the
|
Code That Configures Scene Configuration (Steps 1–4)
%% STEP1 % Specify the location of the support package project files and a local folder destination % Note: Only one path is supported. Select latest download path. dest_root = "C:\Local"; src_root = fullfile(matlabshared.supportpkg.getSupportPackageRoot, ... "toolbox", "shared", "sim3dprojects", "spkg"); %% STEP2 % Specify the location of the Unreal Engine installation. ueInstFolder = "C:\Program Files\Epic Games\UE_4.26"; %% STEP3 % Copy the MathWorksSimulation plugin to the Unreal Engine plugin folder. mwSimPluginName = "MathWorksSimulation"; mwAutoPluginName = "MathWorksAutomotiveContent"; mwRRPluginName = "RoadRunnerMaterials"; mwPluginFolder = fullfile(src_root, "plugins"); uePluginFolder = fullfile(ueInstFolder, "Engine", "Plugins"); uePluginDst = fullfile(uePluginFolder, "Marketplace", "MathWorks"); cd(uePluginFolder) foundPlugins = [dir("**/" + mwSimPluginName + ".uplugin"); dir("**/" + mwAutoPluginName + ".uplugin"); dir("**/" + mwRRPluginName + ".uplugin")]; if ~isempty(foundPlugins) numPlugins = size(foundPlugins, 1); msg2 = cell(1, numPlugins); pluginCell = struct2cell(foundPlugins); msg1 = "Plugin(s) already exist here:" + newline + newline; for n = 1:numPlugins msg2{n} = " " + pluginCell{2,n} + newline; end msg3 = newline + "Please remove plugin folder(s) and try again."; msg = msg1 + msg2 + msg3; msg = strjoin(msg); warning(msg); else try copyfile(fullfile(mwPluginFolder, 'mw_automotive'), uePluginDst); disp("Successfully copied MathWorksAutomotiveContent to UE4 engine plugins!") catch warning("Could not copy MathWorksAutomotiveContent plugin to UE4 engine plugins!") end try copyfile(fullfile(mwPluginFolder, 'mw_simulation'), uePluginDst); disp("Successfully copied MathWorksSimulation to UE4 engine plugins!") catch warning("Could not copy MathWorksSimulation plugin to UE4 engine plugins!") end try copyfile(fullfile(mwPluginFolder, 'mw_roadrunner'), uePluginDst); disp("Successfully copied RoadRunnerMaterials to UE4 engine plugins!") catch warning("Could not copy RoadRunnerMaterials plugin to UE4 engine plugins!") end end %% STEP4 % Copy the support package folder that contains the AutoVrtlEnv.uproject % files to the local folder destination. projFolderName = "AutoVrtlEnv"; projSrcFolder = fullfile(src_root, "project", projFolderName); projDstFolder = fullfile(dest_root, projFolderName); if ~exist(projDstFolder, "dir") copyfile(projSrcFolder, projDstFolder); else warning("Delete old project before installing newer version") end
If you want to use a project developed using a prior release of the Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects support package, you must migrate the project to make it compatible with Unreal Editor 4.26. See Migrate Projects Developed Using Prior Support Packages. Otherwise, you can Customize Scenes Using Simulink and Unreal Editor.
See Also
Simulation 3D Scene Configuration