Unreal Engine 4 with Perforce Source Control

When you start with your Game Development Project , you want to be sure your changes are consistent and safe. Especially when you’re working with multiple people on the same project. I wrote this little tutorial to give you a start into Source Control.

We’re using Source Control with three People working on our Project Presence:Origins. Our current setup is pretty small and basic.

 

What do you need for Source Control in Unreal Engine 4?

  1. A small VPS/Linux Server (1GB RAM, 1Ghz and Space for your Project)
  2. Perforce
    1. Free for Small Teams – Helix Core is free for teams up to 5 users.
    2. P4D (Source Control Server) – https://www.perforce.com/downloads/helix-core-p4d
    3. P4V (Source Control Client) – https://www.perforce.com/downloads/helix-visual-client-p4v
  3. Unreal Engine 4 (duh!)

So let’s get started!

Install Perforce on your VPS (Ubuntu 16.04)

Configure the Helix Server package repository

As root, run one of the following:

Create the file /etc/apt/sources.list.d/perforce.list with the following content:

deb http://package.perforce.com/apt/ubuntu/ precise release

Import the Helix Server package signing key.

wget -qO - https://package.perforce.com/perforce.pubkey | sudo apt-key add -

Install the appropriate Perforce service package.

$ sudo apt-get update
$ sudo apt-get install helix-p4d

The Installation should finish with this informations:

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: Thank you for choosing Perforce Helix
:: The following has been installed by the 'helix-p4d' package:
::
:: - The Helix Version Engine (p4d)
:: - A 'perforce' system user
:: - p4dctl, a tool for managing Perforce service instances
:: - The Helix Command-Line Client (p4)
::
:: The Helix Version Engine is now installed, but not yet configured.
:: You must run the following to configure p4d (as root):
::
:: sudo /opt/perforce/sbin/configure-helix-p4d.sh
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 

Configure Perforce (P4D)

After the helix-p4d package has been installed, additional configuration is required. Perform the following steps:

$ sudo /opt/perforce/sbin/configure-helix-p4d.sh

At each prompt, you can accept the proposed default value by pressing Enter, or you can specify your own value.

You can go pretty much with the proposed default values.

 

Installation Output

Please provide the following details about your desired Perforce environment:

Perforce Service name [master]:
Service master not found. Creating...
Perforce Server root (P4ROOT) [/opt/perforce/servers/master]:
Create directory? (y/n) [y]: y
Perforce Server unicode-mode (y/n) [n]:
Perforce Server case-sensitive (y/n) [y]:
Perforce Server address (P4PORT) [ssl:1666]:
Perforce super-user login [super]:
Perforce super-user password:
Re-enter password.
Perforce super-user password:

Configuring p4d service 'master' with the information you specified...

Started 'master' p4d service.
Started 1 services.
Establish trust relationship with SSL-enabled server...
The fingerprint of the server of your P4PORT setting
'ssl:1666' (127.0.0.1:1666) is not known.
That fingerprint is E1:BB:F7:9C:13:63:75:A4:4D:5A:22:1D:BA:5E:FA:08:CE:74:A2:67
Added trust for P4PORT 'ssl:1666' (127.0.0.1:1666)
Also adding trust to calling user 'ubuntu'.
Creating super-user account...
User super not changed.
Server ID: master
Initializing protections table...
Protections saved.
Setting security level to 3 (high)...
Counter security set.
Setting password...
Creating ticket for root user
Also creating ticket for calling user 'ubuntu'.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: P4D configuration has completed successfully.
::
:: Here is what has been done so far:
::
:: - Your p4d service settings have been written to
:: the following p4dctl configuration file:
:: /etc/perforce/p4dctl.conf.d/master.conf
:: - The p4d service has been initialized with the P4ROOT:
:: /opt/perforce/servers/master
:: - The p4d service has been started with the P4PORT: ssl:1666
:: - The p4d service has been set to Security Level 3.
:: - The new Perforce super-user 'super' has been created and the
:: password has been set to the one specified.
::
:: Here is what you can do now:
::
:: - You can manage it with the 'perforce' user, using the following:
::
:: sudo -u perforce p4dctl <cmd>
::
:: - You can connect to it by setting the P4PORT and P4USER
:: environment variables and running 'p4 <cmd>'. For example, run:
::
:: export P4PORT=ssl:1666
:: export P4USER=super
::
:: p4 login
::
:: For help, run:
::
:: p4 help
::
:: - To connect to this p4d service from another machine, include
:: this machine's name or IP address in the P4PORT. For example:
::
:: export P4PORT=ssl:123.45.67.89:1666
::
:: - For help with creating Perforce Helix user accounts, populating
:: the depot with files, and making other customizations for your
:: site, see the Helix Versioning Engine Administrator Guide:
::
:: https://www.perforce.com/perforce/doc.current/manuals/p4sag/index.html
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 

Check if Perforce is running

ubuntu@ip-123-45-67-89:~$ ps ax | grep p4d
2835 ? Ss 0:00 p4d [master/ssl:1666]
2915 pts/0 S+ 0:00 grep --color=auto p4d

 

The Perforce Source Control Server is ready to go. Beware this is a super basic setup. If you need more detailed information I would recommend the Perforce HelixCore Documentation.

 

Install Perforce Client (P4V) on your Windows-Client

Setup P4IGNORE for Intermediate/Saved Folder

Intermediate and Saved are created as the project is loaded the first time. Over time the Intermediate Folder can grow quite large, as we don’t need these files on our Source Control Server, we’ll ignore them.

To ignore Files you need to create a P4IGNORE File into your project folder. For example create a p4ignore.txt and put the following lines into the file:

Intermediate/*

Saved/*

Now create a environment variable called P4IGNORE and set the Value as Path to the p4ignore.txt.

 

Install the Perforce Visual Client (P4V) on your Windows Client

Download and Install the Perforce Client for your Platform: https://www.perforce.com/downloads/helix-visual-client-p4v

Trust the created SSL Certificate by Perforce.

You’ll be prompted for Remote Server Credentials

For the SSL Connection enter Server: ssl:xxx.xxx.xxx.xxx:PORT the User: super

Click on NEW to create a New User. This is necessary because the User super can’t have a Workspace.

Click on NEW to create a New Workspace. Choose your exisiting Project Folder. P4V will tell you, that the Folder already exist. Choose No to use the selected directory.

You can now click on OK to login.

You’ll be prompted to Add Files to Server. Click on Browse to choose your Project Folder.

Important! P4IGNORE isn’t used for the initial populating the Server. So you have to manually remove Intermediate and Saved before you proceed.

It should show all Files and the Size that will be uploaded to the Perforce Server. Click Next and you’ll see the Ready to Add Files Screen with a Overview about Files and Size of the Files. Click Start and Wait till the Server is populated (grab a Coffee).

After the Upload is finished, you should see the files under Depot. Now you’re ready to go to use your own Perforce Source Control Server.

The P4V Client is necessary to establish the Connection to you Perforce Server. You’ll be prompted to enter your password for the current Perforce User. If you do this, you can work within Unreal Engine 4 with Perforce Source Control. If you don’t start and login in Perforce BEFORE you open Unreal Engine, otherwise you’ll receive Errors when you try to save your Assets.

It’s always a good idea to open P4V before you use UE4 and use Get latest. 

Hint: Click on the Root Folder (f.e. depot) to be sure you’ll receive all new files underneath the root.

 

Setup Unreal Engine 4 for Perforce Source Control

We’re pretty much done with the whole setup. Now it’s time to setup Unreal Engine 4 with Source Control.

After you loaded up you Project, click on Source Control, Connect to Source Control…

Choose Perforce as Provider and enter the Source Control Address (f.e. ssl:123.45.67.89:1666) and your Username (Case-sensitive). Now you should able to select your Workspace and you can Accept Settings.

Done! You’re now ready to use your Source Control within Unreal Engine 4!

When you change Files in Unreal Engine 4 will ask you to Checkout the File. Over the Source Control Button you can always Checkout all „changed“ files in UE4. After you saved everything and ready to Submit all Changes to the Perforce you can click on Source Control and choose Submit… Enter a Description for the Change and Submit the Files!

Yey!

Perforce will set ALL Files as Read-Only! If you want to Cook your Game, you have to set ALL FILES as Non-Ready-Only. Otherwise you’ll receive errors while building the Game.