Custom C++ UObject Class Reference Resetting After Restarting Editor

Issue:

Look like your Construct node not used in any Event chain and just reset.

(post deleted by author)

that doesn’t seem to be the case since I first tested with linked nodes and it didn’t work so I made a video of the issue (and in the video yea the node isn’t connected)

i’m not BP expert by i think Construction node can’t create Native c++ object. Try create BP class inherited from c++ TestCubeData and select BP class version in Construction node.

(post deleted by author)

are you sure? because the code is working with readable custom data, but it resets just after restarting the editor, I looked into this and there seems to be similar issues, I tried creating a blueprint class inherited from c++ class, but now that class can’t be constructed from ‘Construct Object From Class Node’, and.. ‘Spawn Actor From Class’ since that one is 4 actors

.

Try remove all UCLASS specifier from TestCubeData.

why though?, tried, same result

P.S: also UTestCubeItemData inherits from UInventoryItemData, I tested with UInventoryItemData, restarting the editor, again same result

Your main problem with the project is that you are running the uproject while having custom c++ classes. You need to run your project from your IDE in order to retain them safely.

The engine is losing the class data upon reset because of this. (You are basically running the project in semi blueprint only mode)

As you can see, if the project is launched from the ide it retains the c++ class.

(post deleted by author)

oh I see!, I come from a unity background so I wasn’t familiar with C++ coding in UE, also I seem to run into an error when I hit ‘Start Without Debugging’

Error:

F:\Epic Games\UE\UE_5.6\Engine\Source\Programs\UnrealBuildTool\bin\Development\UnrealBuildTool.exe (process 15600) exited with code 1 (0x1).

a quick search revealed that it could be due to missing or corrupted visual studio components, this is what I have, am I missing something here?

P.S: also thanks :smiley: for taking your time to post a video

.

You error is due to not building your game. The vs solution has a couple of projects mix in with your game project (by design)

You have

  • the engine source solution => comprised of multiple internal projects
  • your game solution => game source
  • extra rules and configs generated by unreal.

The default project is always in bold letters and is built when you press the compile button.
You have unreal build tool set as your default and not your game. (You can also set this from the dropdown in the tool bar next to the platform information)

Right click your survival game project and choose set as startup project. The errors should go away if you don’t have any syntax errors in your project.

You can also right click your project and choose “build”, this will compile the project without running it, you can at least check if there are not errors this way.

ahh had some issues setting up C++ classes at first, might have switched the default project that time, so I updated my starter project, right clicked SurvivalHorror and hit build, launched UE from ‘Start Without Debugging’, created a new blueprint actor class, used ‘Construct Object From Class’ node linked with my custom C++ class, compiled and saved and closed the editor and again launched from Visual Studio and still the same result ahh :sob:

here is a video:

look like bug, try regenerate project files and make full rebuild.

I tried deleting Binaries, Intermediate, and the .sln file, right clicking .uproject file and hitting ‘Generate Visual Studio project files’, cleaned and rebuilded the solution, still the same result

Make sure that the header file is inside of the game projects source folder. VS sometimes puts it inside of the intermediate folder (very frustrating). This can cause the file to not be seen by the project correctly.

Go into the folder where your custom header files exists. You can right click the file in vs and open folder where the file resides. If it’s in the intermediate folder then cut it and paste it into the source folder and then from within vs choose add existing file and reimport the header file.

It might also be a file visibility problem though it would throw a compiler error if a file was not found correctly

Also if you moved the files at any point in the project, fixing redirects from the content browser can sometimes fix weird issues.

You can always try a fresh project with just the header and see if it behaves as expected. You could then narrow down the cause.

the .h file seems to be in the source folder, I did ran into some issues while starting C++ coding, don’t remember much, but its possible that something happened, for now I’m gonna create a new project and try testing things out

dang things are okay in my new project so it seems I might have run into some issues whenI first started coding at C++, I do remember doing some nugget package updates because of the warning message, it might be because of that, not sure but I think I have to migrate my project files to fix this

1 Like