Download

Code Migration Difficulties

I just spent the better part of today recreating a lot of work. I’m hoping someone can either tell me a better way, or Epic can put this on a list of possible future improvements.

I’ve been working on AI stuff in a separate project from the main game. My schedule is sporadic, so to avoid causing problems for the full-time developers, I worked apart from the main project. I got things to a good state and was ready to bring my work over to the main project.

Most of the work I did was in C++ classes which were subclassed by blueprint. The C++ code was easy to move over - I just had to change the class macro name. But, apparently, the class macro name is part of how Blueprints recognize their parent class, similar to a namespace (or perhaps, it actually uses C++ namespaces - I haven’t dug into the macro too closely).

Because of that, when I subsequently migrated all my blueprints that were subclassing my C++ classes to the new project, they broke because the superclass could not be found (RepublicSniper.EnemyCharacter is not the same as RepublicSniperAI.EnemyCharacter). Worse than that, reparenting a blueprint is only available if you can actually open a blueprint, but it wouldn’t let me open the broken blueprints.

After a considerable amount of trying to get them to work (including a quickly abandoned foray into trying to edit the blueprint asset with a hex editor), I ended up recreating all my blueprint logic - dozens of them - from scratch.

It feels like there has to be a better way to migrate mixed C++/Blueprint projects that I somehow missed, because if not… well, it really should be easier to share or re-use code between projects.

Hi Jeff,

In your DefaultEngine.ini, add redirectors from the old module to the new module:

[/Script/Engine.Engine]
+ActiveClassRedirects=(OldClassName=“MyClassName”,NewClassName="/Script/MyNewModuleName.MyClassName")
etc…

Cheers,
Michael Noland

When you rename things like that, you need to let the engine know where you put them by using an ActiveClassRedirect. That stores the mapping from old to new, and lets problems like these be fixed up automatically.

To do this, add a line like below to your game’s Config directory:
+ActiveClassRedirects=(OldClassName=“RepublicSniper”,NewClassName=“RepublicSniperAI”)

Great, thank you both. This will be a huge help in the future.