Perforce Setup for Unreal Engine

Setting up Perforce to work with Jenkins and Unreal Engine

Thu, 06 Oct 2022

I’m going to try to make this as simple as I can. Perforce’s Helix Core software is complex. I do think they do a good job of making it friendly to follow, yet its still hard to master.

Prereqs

Download the following software

Visual Client for Workstations

Helix Core for Server

Termninology

This tutorial isn’t here to teach you how to use Perforce. There are some good resources out there that will help you that Perforce created. I will drop some quick terminology to give everyone a baseline. I will be comparing to Git terms

  • Helix Core - We normally just hear Perforce as the SCM(Source control management) software. Thats incorrect, Perforce makes the software Helix Core which is ultimately what we use in Unreal Engine
  • Depot: Similar to a repository. This is the base store of your projects files inside of helix core
  • P4: The cli tool that gets installed that allows us to work with Helix Core. Basically the git cli tool
  • Stream: A git branch. Streams have types that basically describe the relationship flow. Release is a stream that doesn’t let children push to it but it can push to children. Mainline is your baseline of your depot, a main/master branch. Development is a stream that lets you push and pull from it in any direction. Task is like a development stream, except its metadata is slimmed down. Used like a feature branch.

Installation

There are a few ways you can do this. I opted for speed over doing things correctly this time around so my installation is on my local machine rather than a cloud provider. I will be running through this tutorial as if you installed perforce on the same computer that you will be working on. I recommend cloud hosting if you are working on your project with multiple people. It can be cheap depending on your project size. Once I hit early access with my game, I plan on switching everything to the cloud to have more reliable and consistent infrastructure

One Click Solution

If you want to use a cloud provider with a one click solution there is one for digital ocean as well as azure. I haven’t used either of them so let me know how they work for you

In my opinion, Digital Ocean is the cheaper and easier to use option. They actually include instructions. You can sign up for Digital Ocean with this link and can host it for as little as $4/mo(6 with backups which I recommend)

Local Install

Run the Helix Core installer. When prompted, set your P4Port to localhost:1666 and your Perforce Root to the directory where you want your data to be stored at.

The installation should be quick, once thats done you can install the p4v software. When installation, make sure you check off that you want the p4v command., p4 merge and p4 admin.

Setup

You will now have 3 new programs on your computer. The ones we will use mainly is p4v which is the perforce visual client. Its similar to Gitkraken or Github Desktop for git. The second program is p4admin which is what we will use for setting up our Depot.

  1. Create a new Depot. File -> New -> Depot and enter name. My game is Edgemaul Legends, I named my depot edgemaul-legends
  2. Open P4V(program installed on your computer from the second installer)
  3. Create a new mainline stream. Click View on the toolbar -> Stream Graph. Once there right click inside of that window that popped up and click New Stream. On the Stream Type dropdown, select Mainline. I named my main stream, main. It can be whatever you want it to be
  4. The client will ask you to put files inside of the stream now or do it later. I usually opt to do it now. Here you can just drag and drop your projects files inside of the upload menu. Be mindful to skip the Intermediate, Saved and Binaries directory for your project as well as any project level plugins you may be uploading
  5. Once this is done, you’re ready to use Perforce! Open your project in Unreal Engine. I’m using Ue5 so I’ll describe those steps. In the bottom right, hit Source Control -> In the dropdown click Perforce -> for the workspace click the dropdown and select the one option -> hit okay. Unreal engine should now be handling checking in and out assets for you

Workflow

Here is a quick look at my workflow. Lets assume I’m working on version 0.1 of my game and I’m implementing the baseline for my loot system. I would do this for my streams

main
└───dev_0.1
      └───task_0.1-loot_system
      └───task_0.1-some_other_task

We have the base of our depot, main, our dev branch which I make one for each version, dev_0.1 and then the tasks for each dev branch which I use task_0.1-feature. Mind you, this is my way. Its not the only way nor am I saying this is the correct way. This just works for me. I opt for this way since it allows me to make bitesized features that I can iterate on with tests and validating builds frequently

One thing to note, if you are working with multiple people. Perforce will lock any file you’re working on so there are no merge conflicts in other branches. For whatever system you come up with, you want to be mindful of this. For example, I may not want to try to have 2 people work on the inventory system as they may step over each others toes and create messy conflicts

Bonus

I would consider applying these bonus features. I use the typemaps feature to tell Perforce how to handle my files when I upload as well as how many revisions to keep. I set the revisions to 3 just so I won’t keep a mass amount of files on my server. If storage cost isn’t an issue, I would consider keeping all revisions

Typemaps

Info on Typemaps

This is the typemap that I use for Unreal Engine

	binary+w //....exe
	binary+w //....dll
	binary+w //....lib
	binary+w //....app
	binary+w //....dylib
	binary+w //....stub
	binary+w //....ipa
	binary //....bmp
	text //....ini
	text //....config
	text //....cpp
	text //....h
	text //....c
	text //....cs
	text //....m
	text //....mm
	text //....py
	binary+lS3 //....uasset
	binary+lS3 //....umap
	binary+lS3 //....upk
	binary+lS3 //....udk
	binary+lS3 //....ubulk

What I want you to pay attention to is the binary+lS3. This will tell perforce to lock these file types when checked out and only to save a max of 3 revisions for the file types.

If you want to set your own typmaps, open a cli and type in p4 typemap. Perforce will open your text editor and load the current type map settings. To save it you must edit the file, hit save and then close out of the editor

P4Ignore

This I definitely recommend. This will keep you from accidentally checking in files and folders like Binaries and Intermediate.

You want to create a text file and put this in its contents. Feel free to add anything that you feel like is missing

Saved/
LocalBuilds/
*.csproj.*
.vs/*
*.pdb
*.suo
*.opensdf
*.sdf
*.tmp
*.mdb
obj/
*.vcxproj
*.sln
*-Debug.*
FileOpenOrder/
*.xcworkspace
*.xcodeproj
./Makefile
./CMakeLists.txt
.ue4dependencies
Samples/*
FeaturePacks/*
Engine/Documentation/*

# Engine intermediates
Engine/Intermediate/*
Intermediate/

# Intermediate folders for programs should not be checked in
Engine\Programs\*\Intermediate\*

# Intermediate folders created for various C# programs
Engine\Source\Programs\*\obj\*

# Saved folders for programs should not be checked in
Engine\Programs\*\Saved\*
Engine\Programs\UnrealBuildTool\*

# Derived data cache should never be checked in
Engine/DerivedDataCache/*

# Ignore any build receipts
Engine/Build/Receipts/*

# Ignore personal workspace vars
p4config.txt

# Ignore Unix backup files
*~

# Ignore Mac desktop services store files
.DS_Store

# Ignore crash reports
crashinfo--*

# Ignore linux project files
*.user
*.pro
*.pri
*.kdev4

# Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

# Ignore documentation generated for C# tools
Engine/Binaries/DotNET/UnrealBuildTool.xml
Engine/Binaries/DotNET/AutomationScripts/BuildGraph.Automation.xml

# Ignore version files in the Engine/Binaries directory created by UBT
/Engine/Binaries/**/*.version

# Ignore exp files in the the Engine/Binaries directory as they aren't C/C++ source files
/Engine/Binaries/**/*.exp

# Ignore Swarm local save files
Engine/Binaries/DotNET/SwarmAgent.DeveloperOptions.xml
Engine/Binaries/DotNET/SwarmAgent.Options.xml

# Intermediary Files
*.target.xml
*.exe.config
*.exe.manifest

# Ignore project-specific files
*/Build/Receipts/*
*/DerivedDataCache/*
*/Binaries/*
*/Intermediate/*

# idea
# Default ignored files
/shelf/
/workspace.xml

# vs code

/.vs/
.vs/
.vs/*

*/.name/*
/.name

Once you save the file open the cli and type in the command

p4 set P4IGNORE=FILELOCATION

Restart your p4v client if you had it open

Buy Me A CoffeeDigitalOcean Referral Badge
Loading...
Edward Beazer

Edward Beazer - I just like to build shit. Sometimes I get stuck for hours, even days while trying to figure out how to solve an issue or implement a new feature. Hope my tips and tutorials can save you some time.