RESOLVED: UE5 Dropping Parent Classes W Every Restart

UPDATE: Disabling live coding got rid of the problem. I guess the feature is more experimental than I would like it to be. Still don’t understand the issue.

" Blueprint could not be loaded because it derives from an invalid class. Check to make sure the parent class for this blueprint hasn’t been removed! Do you want to continue (it can crash the editor)? "

To replicate:

  1. Create C++ class for Projectiles
  2. Create BP child from C++ for Projectiles
  3. Assign BP to spawn actor for Pawn
  4. Test, works fine
  5. Save, restart UE5
  6. BP for Projectiles now cannot be loaded because it derives from an invalid class

This seems really common with no clear answer on why its happening. Recreating the class and BP works for that instance, but fails again upon reload of UE5.

This is getting very frustrating, it happens randomly throughout projects and I’m no longer interested in quick fixes; I want to understand what is happening.

Thank you in advance.

Does the problem appear when you spawn the projectile from c++ or when you open the BP in the editor?

Hi mate, I had a similar issue when I loaded up my project today. Thought I’d lost a load of progress the first time it happened!

The way I fixed it was I ran Refresh Visual Studio Code Project from the Tools menu, closed out of UE5, then from VS Code I executed the build task (Ctrl-Shift-B) for “ToonTanksEditor Win64 Development Build.”

Not sure if the vs refresh was necessary or not, but once the build task finished I launched the project again from the Unreal launcher and all was well. No idea of the cause, either, but I’ve run into it a few times since I started using UE5. Hopefully someone is able to work out what the root cause is. I know you said that you’re not interested in a quick fix, but at least this might be a wee bit better than having to recreate the class and BP each time.

1 Like

It appears when I launch the project in the editor.

I’ll give that a shot, thanks for your input. At the very least it’s a faster fix than running through deleting files and restoring them

I appreciate your input, unfortunately that did not resolve the issue.

I see you’ve found something that works for you, but just incase here is my solution to this problem. When I load my project I get all the errors for my c++ classes and children. The solution I’ve found is if you recompile with live coding, then reload your blueprints under asset actions, then reload your map, everything seems to load in fine.

1 Like

That’s an interesting approach, I might try it if this happens again and see if it yields more stable results. For now, I guess I just have to live without Live Coding. Lol

Unreal specifically suggests you don’t use Hot Reloads as apparently it can cause data corruption (like Live Coding doesn’t !!). I was using it myself for the same issue of lost Blueprints on an editor restart.

As stated in a previous post when your C++ class vanishes on reload you can (mostly!) click the live code button in unreal and everything starts to work again, but occasionally you get orphaned classes which the editor seems unable to fix. Even if it works, saving everything in Unreal then restarting causes everything to break again. Eventually you end up with such a mess a live compile won’t fix it.

None of this is extensively tested but I’ve been experimenting and have been fixing this by creating a batch file to delete everything in the binaries folder. A desktop shortcut to a “CleanUp.bat” in *\binaries" that contains:

cd Win64
del .

Close down Unreal and your code editor, run the batch file, then re-open the code editor and build solution/project then finally you restart Unreal.

This allows me to rebuild the entire project fresh. I can then restart Unreal and, assuming the project wasn’t too badly broken, all my blueprints are back and the problem is gone.

Oh, and if you want to go back to Live Coding after using Hot Reloads and haven’t cleaned the whole binaries folder you do need to delete the Hot Reload files which are built or Unreal won’t allow you to re-enable Live Coding. They all have 4 numbers in the file name, but it seems safe to just delete all the object code in that folder anyway.