Main Content

Install Support Package and Configure Environment

To customize scenes in the Unreal® and use them in Simulink®, you must install and configure the Vehicle Dynamics Blockset™ Interface for Unreal Engine® 4 Projects support package.

Verify Software and Hardware Requirements

Before installing the support package, make sure that your environment meets the minimum software and hardware requirements described in 3D Visualization Engine Requirements and Limitations. In particular, verify that you have Visual Studio® 2017 installed. This software is required for using the Unreal Editor to customize scenes.

Install Support Package

To install the Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects support package, follow these steps:

  1. On the MATLAB® Home tab, in the Environment section, select Add-Ons > Get Add-Ons.

  2. 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.

  • A plugin file, MathWorkSimulation.uplugin. This plugin establishes 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).

StepDescription
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 C:\Program Files\Epic Games\UE_4.23.

3

Copy the MathWorksSimulation plugin to the Unreal Engine plugin folder.

4

Copy the support package folder that contains the AutoVrtlEnv.uproject files to the local folder destination.

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", "automotive");

%% STEP2
% Specify the location of the Unreal Engine installation.
ueInstFolder = "C:\Program Files\Epic Games\UE_4.23";

%% STEP3
% Copy the MathWorksSimulation plugin to the Unreal Engine plugin folder.
mwPluginName = "MathWorksSimulation";
mwPluginFolder = fullfile(src_root, "PluginResources", "UE423"); % choose UE version
uePluginFolder = fullfile(ueInstFolder, "Engine", "Plugins");
uePluginDst = fullfile(uePluginFolder, "Marketplace", "MathWorks");

cd(uePluginFolder)
foundPlugins = dir("**/" + mwPluginName + ".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;
    warning(msg);
else
    copyfile(mwPluginFolder, uePluginDst);
    disp("Successfully copied MathWorksSimulation plugin to UE4 engine plugins!")
end

%% STEP4
% Copy the support package folder that contains the AutoVrtlEnv.uproject
% files to the local folder destination.
projFolderName = "AutoVrtlEnv";
projSrcFolder = fullfile(src_root, projFolderName);
projDstFolder = fullfile(dest_root, projFolderName);
if ~exist(projDstFolder, "dir")
    copyfile(projSrcFolder, projDstFolder);
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.23. See Migrate Projects Developed Using Prior Support Packages. Otherwise, you can Customize Scenes Using Simulink and Unreal Editor.

See Also

Related Topics