Saving variable values made in C++ but put in through Unreal Engine

I’m just learning through Unreal Engine but I have problem with Unreal not saving the variables and its values if the variable was made in C++.

Here’s the breakdown:

  1. In Visual Studio, I create a variable - for example:
    UPROPERTY(EditAnywhere, Category=Moving Platform)
    FVector PlatformVelocity;
  2. I compile it in Unreal Engine and I now see the variable “Platform Velocity” as an X,Y,Z vector and all is good.
  3. I set the Velocity for say X=500.
  4. Save the map and close Visual Studio and Unreal Engine.
  5. Later I load the map again with Unreal Engine.
  6. “Platform Velocity” is now gone so I recompile and the variable comes back but now it’s blank again.

Is there some sort of setting in Unreal Engine that preserves the value for that variable so I don’t have to re-enter it everytime I load the map in Unreal Engine?

1 Like

Looks fine. The question is what is the class around it? How do you create the object with the variable.

1 Like

It’s just a basic Actor C++ Class.

And have you created an instance of it? By placing it in the scene? Or do you happen to have created a Blueprint from it? Where do you try to change the variable? Where do you see it?

Just a side note that i ran right into: If you start Unreal via Visual Studio debugging, and you changed the configuration to, lets say “Debug game Editor”, and modifying your code under this configuration and saving the unreal project. If you now open the same project from the launcher, it will be opened with outdated code, as it used the build with “Development Editor” … If all that sounds strange to you, than ignore all that, as it is most likely not your problem.

Thanks but I ended up figuring it out.

There’s a bit of bug between Visual Studio and Unreal Engine’s communication using Live Coding. It seems you have to close Unreal Editor, Run a Build Task in Visual Studio, and then re-open Unreal Editor for the changes you made earlier to stay visible.

Ah, now i understand. Yes, my advise is to only rely on a LiveCoding rebuild, when changing something in your cpp files. There might be exceptions, but better be safe than sorry.

1 Like

yes if you only livecoding rebuild, that will not be available if you launch the binary again without recompiling. (if you always launch using VS, though, then it will handle recompiling anyway)