This tutorial will cover the entire process of setting up your Perforce server with Unreal Engine 4 on Windows!
Step 1: Install P4 in Assembla
You need first a perforce repository installed in your Assembla Space. To do that you need to go to Admin > Tools and click on the Add button on the P4 repository.
Note: You can install more than 1 repository in the same space.
If you signed up with Google / Slack / Github then you need an assembla username and password. You can set an assembla password and get your username (aka login) from your profile page.
Step 2: Install Perforce on your machine.
You will need a p4 client. You can install the p4v visual client and p4 command-line from this link.
Step 3: Launch P4V.
Now you need to create your workspace. A workspace is simply a folder in your computer where you will have all your code. I will call mine UE4.
Open your CMD and CD to that workspace. Create the p4config.txt file and add the variables. It is recommended to set the full path to the p4config.txt file in P4CONFIG. When copying the P4HOST windows has issues copying ^ so you will need to edit the final fill and add the ^ to P4HOST to ensure you can route to your repo. On Mac and Linux this is non-issue.
Note: You can find all the details on your P4 Instructions tab in Assembla.
Make sure you are connected to p4, to do that just run this command
p4 info and it will show this output
p4 login to make sure you can connect. Enter your password
p4v and press Enter. You will see a window asking you for your Server, User and Workspace (optional and we don't need it).
We need to create a workspace at p4v level. Click on "New Workspace".
Now let's enter a name. Make sure to browse your local workspace.
Now let’s choose a stream. Click on "Browse" next to Stream and you will see the "Mainline" stream. Select it and click OK.
Check one last time everything is fine, then click on OK.
You will be asked to choose a different location for the workspace. You will click on NO because we want to use that workspace.
It should look like this.
Step 4: Move files into your workspace.
If you already have your project, you can copy them into your workspace, but do not include its root folder.
Click "Refresh" in P4V to show the new files.
Step 5: Add files and folders to your depot .
We now see our local files in our p4v! Yay! But that's not it, we still need to send them to our p4 repo in Assembla. To do that, we need to mark them as "Added" and it's very simple, just select the files or folders you want to add and click on "Add".
Note: If you Add a folder, all the files under it will be mark as added.
You will be asked to select a changelist. Let's select the default and click on OK
This is how it should look. All the files that are added will have a red cross at their left-top. I didn't add my p4config file because it's not part of my code. Also, under the "Pending" tab, you will see all the files that are ready to be submitted.
Step 6: Submit your files to the depot.
Let's submit the files! Click on the Submit button. You will get a new view with all the files that will be submitted.
Before clicking on Submit, make sure to add a description.
Now click on Submit! All the submitted files have now a green mark.
I can see my files on Assembla! We are now ready to connect p4 with UE4.
Step 7: Connect UE4 with P4.
One of the great things about Perforce is that it allows us to avoid merge conflicts and work better in teams because we have to "check out" files to modify them, letting other users know that we intend to submit changes to those files. You can either select a file (or folder) in P4V to check it out, or you can connect UE4 to do this work for you! You'll still have to use P4V to submit changelists on your own, but this is an amazing enhancement to our workflow, so let's set that up.
Open your project (remembering to open the new copy that exists in your workspace) and then click the dropdown next to "Source Control". Now select "Connect to source control".
Select Perfoce and it will autofill the server and user name. You just need to enter your workspace name. Click on "Accept Settings".
Note: In case if you have multiple depots, you must fill the "Host" line in Unreal Editor' Source Control
And you know it's connected because the "Source Control" is green now.
Now, whenever you want to make changes to something inside UE4 you will be asked if you want to check out the file from Perforce. Simply hit “Check Out Selected” and go about your work as usual.
Don’t hit “Make Writable” unless you really need to. This is ignoring what we’re accomplishing by making files need to be checked out in the first place and can cause trouble when working in teams.
Finally, you have to submit your changes. To do that click on Source Control > Submit to Source Control...
Add a description, if you want to reference your commit to an existing ticket in Assembla, use re #ticket_number.
And this is how it looks in your Assembla p4 repository!
If you have any questions or need assistance. Please always feel free to email us at email@example.com. We will be happy to assist.