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.
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
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.
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".
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.
Finally, you have to submit your changes. To do that click on Source Control > Submit to Source Control...
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.
Article is closed for comments.