Build Unreal Engine from Source with Chaos
This is a guide to build Unreal Engine Source with Chaos setup and enabled and build a project with it.
This assumes you already have all the needed tools installed and setup such as Visual Studio and a Github account.
You must link your Github account with Epic Games in order to access the source build from github. This guide from epic will walk you through it: https://www.unrealengine.com/en-US/ue4-on-github
Once you have access to the source build you will want to head here and confirm that the release branch is selected: https://github.com/EpicGames/UnrealEngine
From here you can either close the repository, or click Download ZIP. I recommend saving it to your desktop at first or the root of whichever drive you will be saving it to.
Save to a short path so the path length is short and does not cause any issues with creating the needed files.
Once it has finished downloading (if as a ZIP make sure to extract it before continuing), open it up and run Setup.bat.
This will take upwards of 10 minutes so be patient. Once the command prompt closes it is finished and you can move on.
After that, run GenerateProjectFiles.bat
This will take much less time compared to Setup.bat, but again once it closes it is finished.
After this is all done, its time to move the folder to the location that you desire and rename it to something you want. In my case I moved it to the default installtion folder in Program Files->Epic Games and named it UE_4.27.2_Source.
Make sure to rename it now. Attempting to rename it later after the engine association has been created can create some annoying issues.
Once everything has been done, the project has been moved and renamed, go ahead and open UE4.sln. This will open up the solution for you inside of Visual Studio. Now here there is something else I recommend you build that I will mention after we handle the engine. Once Visual Studio is open, right click on the project called UE4 and set it as Startup Project. Then make sure that the mode at the top is set to Development Editor.
Now we want to make the changes for Chaos. Open up the UE4, Engine, UE4, Source, then UE4Editor.Target.cs
Once thats open, add the following lines to the build target: bCompileChaos = true; bUseChaos = true; bCustomSceneQueryStructure = true;
Once that is done you can either click the green arrow at the top to start building and launch, or right click on UE4 and hit Build. Expect this to take quite awhile as it has to compile several thousand files and generate all the reflection data needed. Go ahead and launch if if you havent already once it is finished compiling (Green arrow at the top) and wait for it to launch and let the shaders compile. Once this is all done go ahead and close the editor, then we can build that other project I mentioned above.
The last thing we need to build is UnrealLightmass. This allows for you to build lighting. Without this, you will have trouble building lighting in your project as it will state Swarm has failed. Go to UnrealLightmass like shown in the image below, right click, and hit Build
Now you are done. You have a ready to go source engine with Chaos setup. Now you just need to set it up in your project. Lets assume you have a project already made that you want to bring over to use this new source build (the same can be followed for new projects as well). Go to your project and open up its solution (assuming its a C++ project). Find your Target.cs files (ProjectName.Target.cs, ProjectNameEditor.Target.cs, and ProjectNameServer.Target.cs). If one of those dont exist, dont worry about it. Open up all of the ones you have and add this to the build target like you did with the engine. Make sure to do it for all of them. bCompileChaos = true; bUseChaos = true; bOverrideBuildEnvironment = true;
If all the above is completed, you should now have a chaos ready engine and a project using it!