This tutorial will cover the entire process of setting up your Perforce server with Unreal Engine 4 on Windows and Mac!
Step 1: Add a P4 depot in Assembla
You need first a perforce repository installed in your Assembla Space. To do that you need to go to Space Settings > Tools and click on the Add button on the P4 repository.
Note: You can install more than 1 repository in the same space.
Step 2: Install Perforce on your machine.
Install p4v visual client and p4 command-line. Choose your family, platform and version.
Below are 2 screenshots that shows how it looks like on Windows + P4V and Mac + command-line
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 MyUE4Game.
Go to your installed perforce repo > Instructions, and paste the server value
Open P4V on your computer. You will see this:
Put the server value you copied and your Assembla username. You can get your username from here (it's case sensitive).
Click on OK. If this is the first time you try to connect to this server, it will ask you to trust the fingerprint. Simply select the checkbox and click on "Connect".
It will now ask you to enter your password.
If you are logging in with SSO, 2FA or MFA then you need an API Secret key. Go here and fill out the form as follow:
Click on "Create" and you should see the new key added. Under your key's secret, click on the "click to show", it will reveal your secret key. Copy it and use it as your password.
Step 4: Create a new workspace
Under "Depot", click on "New Workspace".
Fill in the "Workspace name" field with any name you want.
On "Workspace root", browse the directory where your project will be.
On "Stream", click on "Browse". You will get the following moda. Select the mainline stream and click on "OK".
Check one last time everything is fine, then click on OK.
Note: If it asks you 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 5: Add/move your UE4 project
If you already have your UE4 project, you can copy the content into your workspace. If not, just create a new project and select the workspace directory.
Click "Refresh" in P4V to show the new files.
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! It might take a few minutes or more. Depending on how big your project is.
Once it finishes, all the submitted files have now a green mark.
I can also 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 Perforce
Fill out the form and 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.
If you want to submit your changes, just save them as always.
Right after, you will be asked to check out assets. Simply click on “Check Out Selected” and go about your work as usual.
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 support@assembla.com. We will be happy to assist.