Link to the question on the Unreal Course Community FB group: https://www.facebook.com/groups/unrealcourse/permalink/2692000887729860/?comment_id=2692009394395676
I created a c++ class derived from Pawn, called PlayerCamera. Then, I created a blueprint class based on it, BP_PlayerCamera, and set it as the default pawn class for my custom game mode (which derives from GameModeBase).
Everything executes and works fine until I close unreal and then re-open it: when I do that, BP_PlayerCamera isn’t the default pawn of the game mode anymore, and if I try opening the BP_PlayerCamera editor I get the following message:
“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)?”
Of course the c++ class is still there, I didn’t remove it. Anyways, clicking on YES the blueprint editor opens and, in class settings, the parent class is set to None as the message says. If I try reparenting it, I can’t find my PlayerCamera c++ class among the ones in the list, even though it is still visible from the editor.
Here is the crazy part: if I delete the BP class, recreate it by right-clicking on the c++ class, and set it once again as the default pawn for the game mode, everything works fine again! The c++ class is found and parented correctly to the new BP, I can set this BP as the default pawn for my game mode, and the gameplay behavior is the intended one. Of course, if I close and restart the engine, the problem rises again and I am forced to repeat the same steps to make the BP work, which is very frustrating.
My question is: what the hell is going on? Could this be that some Unreal file somewhere is corrupted, causing my c++ class to not be found when the engine reloads? If so, is there a way to fix this?
Here is a list of things I tried and didn’t do anything:
-
Give a different name to the BP (initially I thought the problem could be that there is an engine pre-built class called BP_PlayerCamera, but no)
-
Create a completely new game mode
-
Deleting the project and cloning it again to get rid of intermediate and binaries folders
-
Deleting the BP and c++ classes along with the binaries folder as explained in lesson 90 of the course, recreating it and copy-pasting the old code in it and recompiling.
-
Using git revert to make sure to wipe out everyting related to the PlayerCamera class and redoing everything from scratch.
I have other blueprints in my project that derive from custom c++ actors and I’ve never had this kind of issue. I created BP from c++ pawn classes in other projects before (ToonTanks) and nothing like this ever happened. What’s incredible to me is that I cannot find anyone online that had a similar problem.
Thanks for your patience and time guys, I really appreciate it! Let me know if you need screenshots, code snippets, link to gitlab project etc.