Download

C++ functions

Is it possible to us the C++ from one project in another project? Lets say the C++ in the shooter game in a blank project.

Yeah but you have to copy it over, nothings stopping you doing that.

You can’t make two different projects talk to each other though.

You should be able to migrate the assets to another project.

I thought that was the idea between network play? :stuck_out_tongue:

Don’t see how to migrate the C++ directory?

Ah, ok. You need to put the code into an asset first.
I put some of my code into an empty dummy actor asset and migrated that to different projects…

I am trying to get the C++ assets(gun, bot, pawn, etc) into a blank project. If you have time could you give me an explicit explanation of how to do this? If I am asking too much, no problem.

For each class you copy over to the new project, you’ll have to delete or change the project macro. Each C++ header file has a macro called PROJECTNAME_API used in the class declaration. It gets removed during precompile so has no effect on compiled code, but must be used by the Unreal build system somehow.

You’ll also have to change the project include at the top of each file to point to the correct project include for the new project.

As long as you bring over all of its dependencies, that’s all you should need to do to make it compile.

The tricky part is if you’re trying to bring over blueprints that descend from the classes you’re copying over. If you do that, you have to add active class redirects to your project to tell the engine where to find the parent class. You can do that in [FONT=Courier New]DefaultEngine.ini, and it looks something like this:



+ActiveClassRedirects=(ObjectName=,OldClassName="FriendController",NewClassName="/Script/RepublicSniper.FriendController",OldSubobjName=,NewSubobjName=,InstanceOnly=False)


In this case, I copied a class called [FONT=Courier New]FriendController from a project I was using to do some prototyping. I also migrated some blueprints that were parented to [FONT=Courier New]FriendController . This redirect tells it to use the version I added to my project ([FONT=Courier New]NewClassName format for C++ classes in your project’s [FONT=Courier New]Source folder is[FONT=Courier New] /Script/[ProjectName].[ClassName])

I seem to remember somebody from Epic making a post that they planned to make migrating C++ an easier process, but I haven’t seen anything more on that recently.