Now we'll make things more interesting by pulling our projectiles from the earlier project in to this AR demo in all their glory. First, though, we'll need to add the source files to the proper folder and then generate project files. To do this, I've made two copies of the project on my local hard drive (which makes GitHub a bit tricky to handle as they're both branches in the same repository); but to keep things simple, I'll work locally with a copy of this branch (simply cut & paste to a new folder):
And have chapter 12's branch here in my normal GitHub local drive location:
This way I can cherry-pick items from chapter 12 into the AR project. In the end, it's a bit complicated, but I'll simply delete my local chapter 12 files and folders when done, except the .git hidden folder for git's information, then move (or rename) the local AR to that location and switch branches back to the AR project and check in those specific changes. Git can be tricky in cases like this, but right now we're just trying to have some fun in an AR environment and see what we can do, so let's get to it!
Copying the source files as noted was the first step, just simply take chapter 12's MasteringProjectile.h and .cpp files, and move them in to the MasteringAR/Source folder. Once that's done, we can right click on the MasteringAR.uproj file and generate project files with our UE4 version, or use a batch file as we have in the past to make sure we have VS 2017 files. Now we can build and run the editor as normal and deploy the project as well. Keep in mind, though, as a C++ project now, iteration times will increase significantly between runs on the device as it will compile code each time it deploys; but that's what we need to do here to get our projectiles firing with all their code of course we built over previous chapters.
A bit unfortunately, we actually need to launch the chapter 12 project to migrate the assets from there, to our AR project. So open it in the editor and we'll browse to the projectiles section of our blueprints and right click on one of them. You'll see this pop-up and under Asset Actions is Migrate.
The next thing that will pop-up is a list, basically, of all the dependencies that Unreal is telling you it will copy, just click ok:
Now we just need to point to our Content folder in the AR project's Content folder, and those projectiles and all their asset dependencies (the special FX we did in Chapter 12, In-Scene Video and Visual Effects, and so on, will all be brought with it). Migrating assets like this is a huge time saver between projects that share them, so I'm glad to finally get a chance to share its use here.
With that done, we can get back to the AR project in the editor once more, make an array of our projectiles, and spawn those instead of the test geometry the project starts with:
And that's it, now we have our core project's projectiles spawning in the AR world with special FX and all!