Replacing Blueprint Variable with C++ variable easier?

Right now since I don’t know the Engine well and C++ I’ve been making my code in blueprints then converting the code to C++, so far it has worked good but I use the same variable names. I like to unlink my blueprints after the blueprint to C++ conversion is 100% done. But I would like those variables to stay hooked up together but reference the C++ ones not the blueprint ones. Is there any way to do this or do I have to do this manually and replug everything in from my inherited C++ variables with the same name. here is a example

http://imagizer.imageshack.com/img913/8255/M6IRzL.png

I have those blueprint nodes hooked up to my original blueprint variables, but now I have the same exact C++ variables exposed under playerstats that was created in C++, is there a quick way to replace those nodes with the C++ ones or do I have to do it manually? This might be considered lazy but whatever can save time is good, with a huge blueprint class converted to C++ it could waste some time relinking everything.

I like to leave the old blueprint there (but unplugged) for my team members and some stuff I keep as blueprint to send to UMG.

1 Like

Since your workflow is to convert to C++ once you are far enough along, I’d start with creating the C++ classes as you go. There you can add the variables but keep the logic in Blueprints until you are ready to move it to C++. That way, you don’t have to worry about making sure which class (BP or C++) has the variable. They’ll always be in the C++ and migration will be easier.

Since this pops up in google searches:

There is the Core Redirects system one can use to achieve this:

For example you have the blueprint MyGame_GameInstanceBP with a variable bGameStarted and you created one in the C++ UMyGameInstance called bHasGameStarted. The redirect would look as follows:

; In DefaultEngine.ini
[CoreRedirects]
+PropertyRedirects=(OldName="MyGame_GameInstanceBP_C.bGameStarted", NewName="MyGameInstance.bHasGameStarted")

Note the addition of _C to the blueprint name and the ommision the U prefix for the C++ class.

After adding the redirect, you can delete the Blueprint variable and all references to it will be remapped to the new C++ variable. As long as the original variable is still there nothing will be remapped.

Now you can do it like this:

  1. Rename your blueprint’s variable, for example MyVariable_old
  2. Create in C++ class new variable and complile
  3. In blueprint right click on MyVatiable_old, and select Replace References
  4. In “Replace with” select your C++ vatiable and press “Find and Replace All References”
3 Likes

I’ve tried to do exactly this, but for some reason the c++ variables don’t show up in the list. Is there something i need to toggle for them to show?

Did you give access to the variable inside the blueprints?
Before the variable you need to add a line with UPROPERTY:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “MyCategory”)
float MyVariable = 100.0f;

Yeah, i can drag them over and replace their counterpart, so they are all good in the blueprint, just don’t show up in replace references. I didn’t add a category if that makes any difference.

Update in 2024.

I just tested this out. I have a blueprint variable. I made a c++ variable of the same name in the c++ parent class. After live compile, the blueprint variable seems to have been automatically replaced.

Very handy!