How to use Core Redirects with C++ variable?

I’m having trouble replacing a blueprint variable with a C++ one from the parent class of the blueprint. I tried using redirects as:

[CoreRedirects]
+PropertyRedirects=(OldName="BP_DoorActor_C.Length",NewName="/Script/LevelModule.DoorActor.Length")

I tried changing the name of the blueprint variable to Length_OLD and also in the redirect, but it doesn’t seem to work. Do you have any idea on how to make it work?

I tried using “Replace references” in the blueprint variable, but for the target it won’t show my C++ variable. The C++ variable has both BlueprintReadWrite and EditAnywhere. I don’t know if this matters, but it is also in the same category as the blueprint variable.

If the property is the same name, you shouldn’t have to do anything.

As for C++ class names, I’ve used the name by itself without the prefix letter. So AMyCharacter is just MyCharacter.

Also, what is CoreRedirects section? All my redirects are in the [/Script/Engine.Engine] section in DefaultEngine.ini

Everywhere I’ve looked I found that I should put my redirects in the [CoreRedirects] in the DefaultEngine.ini file. The property has the same name, but it just doesn’t work. When I build and open Unreal I get an error about the variables having the same name and it renames the blueprint variable to “Length_0”.

Edit: Core Redirects in Unreal Engine | Unreal Engine 5.3 Documentation | Epic Developer Community This is what I mean

You completely rejected everything I’ve indicated. Not much anyone can do for you I’m afraid.

What do you mean? I tried just having the same name for the variable in both the blueprint and the c++ class, but it doesn’t work. It just renames the blueprint variable to Length_0.

I’m not using the prefix letter for the C++ class name as you said, it’s not ADoorActor, it’s just DoorActor.Length.

The CoreRedirects section is what Unreal indicated using for the redirects in the BaseEngine.ini file. I tried putting it in [/Script/Engine.Engine] and it still doesn’t work.

I’m just not sure what I’m doing wrong.

Try these. Only use one at a time.

+PropertyRedirects=(OldName="/Script/MyGameName/BP_DoorActor_C.Length",NewName="DoorActor.Length")

If that doesn’t work, you can be more forceful.

For this, you need the exact FULL path of your BP.

+ActiveGameNameRedirects=(OldGameName="/Script/MyGameContent/Blueprints/Doors/BP_DoorActor_C.Length",NewGameName="DoorActor.Length")

Another thing you could try is reparent to the base class of the C++ class and then reparent back. You’ll lose all the defaults values of anything in the C++ class though (edit: … in any instances).

I have all my redirects in the [/Script/Engine.Engine] section and they all work fine.

edit: Actually, you don’t need the full path in ActiveGameNameRedirects. If you have nothing else called DoorActor, you can actually just use “BP_DoorActor_C.Length”. Try that. You could also try “BP_DoorActor.Length”. The _C is usually for generated classes. So you may not need it.

+PropertyRedirects=(OldName="BP_DoorActor.Length",NewName="DoorActor.Length")

or

+ActiveGameNameRedirects=(OldGameName="BP_DoorActor.Length",NewGameName="DoorActor.Length")

Been reading up on this a bit. It seems that automatic redirect to a base class property is only done when reparenting. So if you just add the same name to the base class, you’ll get a conflict. So you could reparent to the base class of the C++ class and then back and perhaps that would work. Again, you’ll lose any defaults you set in any instances.

I’ve tried both methods (ActiveGameNameRedirects and PropertyRedirects) with and without the _C but I keep geting the same errors no matter what and the renaming to Length_O. The errors are

Internal Compiler Error: Tried to create a property Length in scope SKEL_BP_DoorActor_C, but another object (FloatProperty /Script/LevelModule.DoorActor:Length) already exists there.
Found a member variable with a conflicting name (Length) - changed to Length_0.
Could not find a variable named "Length_0" in '/Game/Level/BP_DoorActor.BP_DoorActor_C'.
Make sure '/Game/Level/BP_DoorActor.BP_DoorActor_C' has been compiled for  Get Length_0
The property associated with  Length  could not be found in '/Script/LevelModule.DoorActor'

I also tried just reparenting to the base class (Actor) and then back to DoorActor, but same thing happens.

Edit: One more thing. Before compiling the blueprint, the name of the blueprint variable is Length_ERROR_DUPLICATE_0. After compiling it changes it’s name to Length_0.

Yeah, duplicates are a pain. I actually have a duplicated class name with something in the codebase and I’ve never been able to use redirects to rename it. It just gives me a warning so I just leave it… but this may be what you’re experiencing. Redirects aren’t for duplicates.

Have you tried renaming your blueprint variable and then using a redirect?

edit: If you can’t get into your project, you may have to comment out the C++ property first. Then bring it back afterwards.

I have tried that earlier. I renamed the blueprint variable to Length_OLD and then set a redirect for it, but it still didn’t work. Didn’t throw any errors, but it did nothing.

One way I kinda forced it to work was by making a struct in blueprints, setting the type of the variable to that struct, deleting the struct type and then setting the redirector. It worked, but I lost all the values in the Set nodes, and I have a lot of those so I don’t think that’s a good idea.

And yeah, already figured out that out. It would not open the project before if I didn’t comment the C++ variable first sometimes. Thanks!

So class or struct redirect worked, but not property redirect? Very strange. The docs say property redirects are for deleted properties. But if you delete a property in BP, it removes all uses of it. I’m guessing it’s actually for when you remove a C++ property.

So if you tried to move a property from C++ to BP, redirect would work. And the other way around is supposed to be fixed by reparenting, but it doesn’t work for you. That’s brutal.

In the past, I’ve renamed the BP variable. Added the C++ property. Then I went to delete the BP variable, it’ll give you a list of nodes still in use. I manually go change all those. And then delete the BP variable. Tedious, but you don’t lose anything. (… unless you have instances of the class with different defaults).

Sorry I don’t have any better alternatives.

edit: I’ll try something later. Busy rn. I’ll post back what I find.

1 Like

Well, I think the struct redirect worked because the variable became invalid. But when the variable is not invalid and is still there (it’s a float, so I have no way to make it invalid afaik), it won’t replace it.

Thank you for taking the time to try to help me though!

If you find anything else let me know!

1 Like

Dunno if it’ll work, but I read a post that someone claims this works. They comment out the C++ property. Load up the project. Uncomment the C++ property and while still in the editor, do a live compile and the variable automatically updated to use the C++ property.

That sounds like voodoo to me if this works, but might be worth a shot.

If it does work, I’d recommend saving, exiting and rebuilding to be safe.

I think I saw the same thread as you did. I tried that before, but I get the same behavior of renaming the blueprint variable to Length_0.

Ok, trying some stuff now…

1 Like

Here’s one thing that works, but is kind of messy. Give the C++ variable a different name. Then right click on the BP variable and select “Replace References”. Select the C++ variable and it’ll update all the nodes. Unfortunately, it won’t connect them. So you have to manually reconnect all the nodes. Then you delete the BP variable as it’s no longer used. You could theoretically rename it back after saving and using a redirect. Then you need to save once again.

Is the C++ variable showing up for you in the Replace References? I already tried that, but for blueprint variables is only showing other blueprint variables to replace it with and for C++ variables only other C++ variables.

Worked fine for me. You have to expand the little arrow thing as the list is collapsed, but it’s there.

Hmmm, weird. For me it doesn’t show any C++ variables. I’ll try more things tomorrow since it’s 4AM for me.

Thank you!

Edit: I also remember reading multiple threads that when replacing BP variables it doesn’t show C++ variables for some reason.