Using Unreal Engine and LychSim on Linux Server#

Set Up WSL for Local Testing#

  1. Install and enable WSL 1. Following the official documentation to set up WSL. In this tutorial, we prefer WSL 1 because of a discrepancy in network access between WSL 1 and WSL 2. Read more here.

    ../_images/linux_01.png

    Setting up WSL 1.#

  2. Install Ubuntu. Run wsl --install -d Ubuntu.

    ../_images/linux_02.png

    Installing Ubuntu.#

    ../_images/linux_03.png

    Installation successful.#

Set Up Build Tools#

  1. Install cross-compile toolchain. Download and install the cross-compile toolchain for Linux from here. Choose the version according to your Unreal Engine version, e.g., download v23 for UE5.5. Verify the installation by running the command below. Reboot your computer after installation.

    "%LINUX_MULTIARCH_ROOT%x86_64-unknown-linux-gnu\bin\clang++" -v
    
    ../_images/linux_04.png

    Cross-compile toolchain verification.#

  2. Enable Linux as target platform in Epic Games Launcher.

    ../_images/linux_05.png

    Enabling Linux as target platform.#

  3. Modify Visual Studio installation to include Linux development with C++ workload.

    ../_images/linux_06.png

    Visual Studio Installer.#

    ../_images/linux_07.png

    Include Linux development.#

Build the UE Project for Linux#

  1. Set up the UE project. Follow this tutorial to set up a UE project with LychSim plugin. Import necessary scenes and assets.

  2. Package the project for Linux. If you don’t see available SDK for Linux development, check the installation of your cross-compile toolchain. Also make sure you have rebooted your computer after installing the toolchain.

    See troubleshooting for a known issue about failure of UbaSessionServer on latest Windows updates.

    ../_images/linux_14.png

    Packaging for Linux.#

    ../_images/linux_09.png

    You should now see a launching script in your project directory or a subdirectory named Linux.#

Run UE Project in WSL#

  1. Locate the launch script. To test it in WSL, identify the path in Windows and in WSL. For example, if your launching script is located at C:UsersusernameDocumentsUnreal Projectslinux_demolinux_demo.sh in Windows, the corresponding WSL path would be /mnt/c/Users/username/Documents/UnrealProjects/linux_demo/linux_demo.sh.

  2. Identify the map name. From the Project Settings -> Maps & Modes in Unreal Editor, you will find a list of maps that are available to launch from. Note the name of the map you want to launch. In this example, the map name is FirstPersonMap.

    ../_images/linux_10.png

    Map name.#

  3. Run the script in WSL. Open your WSL terminal and navigate to the directory containing the launch script. Run the script with the following command:

    linux_demo.sh "FirstPersonMap?listen" -port=7777 -nullrhi -nosound
    
    • -port=7777 specifies the port number for network communication.

    • -nullrhi disables rendering, which is useful for (1) quick tests, or (2) connecting from a UE game client.

    • -nosound disables sound processing.

    ../_images/linux_11.png

    UE5 instance running in WSL and listening on port 7777.#

  4. Connect to the UE instance from Unreal Editor. Open another WSL terminal and identify the IP address of WSL by running ip addr show eth0. Use this IP address to connect to the UE instance from another terminal or machine.

    wsl hostname -I
    

    Now play the game and then run the following command in the Unreal Editor console to connect to the UE instance running in WSL:

    open 192.168.1.169:7777
    
    ../_images/linux_12.png

    Connecting to the UE5 instance from Unreal Editor.#

    ../_images/linux_13.png

    You should also see the connection log in the WSL terminal where the UE instance is running.#

Run UE Project in Linux Server with LychSim#

  1. Transfer the packaged project to your Linux server. For example, you can use scp command to copy the project files from your local machine to the server.

    scp -r C:\Users\username\Unreal Projects\server_demo\Linux username@your_server_ip:~/ue/server_demo
    
  2. Connect to the Linux server and launch the script. Use the map name identified earlier to run the launch script on the server.

    ssh username@your_server_ip
    cd ~/ue/server_demo
    chmod +x ./server_demo.sh
    ./server_demo.sh "FirstPersonMap?listen" -port=7777 -RenderOffscreen -vulkan -windowed -ResX=1920 -ResY=1080
    
    • -port=7777 specifies the port number for network communication.

    • -RenderOffscreen enables GPU rendering without displaying to a physical screen.

    • -vulkan specifies the use of Vulkan rendering API.

    • -windowed -ResX=1920 -ResY=1080 sets the windowed mode and resolution.

    ../_images/linux_16.png

    UE5 instance running on Linux server using GPU rendering.#

  3. Enable remote access. If you want to run LychSim on local machine, enable remote access to port 7777 for UE instance and port 9000 for LychSim server.

    sudo ufw allow 7777
    sudo ufw allow 7777/tcp
    sudo ufw allow 9000
    sudo ufw allow 9000/tcp
    
  1. Now we can use LychSim by specifying the server IP and port number. For example, in Python API:

    from lychsim.api import LychSim
    sim = LychSim(server_name='your_server_ip', port=9000)
    
    ../_images/linux_17.png

    All tests passed successfully!#