VRCharacter C++ Class Disappeared After Importing Assets

Solution: Find your project in your file explorer and delete the Saved, Intermediate, Binaries, and .vscode folders. With UE5 and VSCode closed, right click on your UE5 project file (.uproject extension) and click “Generate Visual Studio project files.” Follow whatever instructions pop up if there are any. Open UE5, open your project, and open VSCode through Tools → Open Visual Studio Code. From what I’ve read, this will fix a majority of problems you have with UE5 and VSCode, not just a similar problem to this.


After importing the new map (I am using Epic’s VisualStudio Map that is compatible with UE5, since the Blueprints map in the video is only compatible with UE4), it appears that my VRCharacter C++ class has just… disappeared. I imported the map as it was shown in the video, but when it first loaded, the “VR Preview” option was greyed out and I noticed that the Default Pawn Class in BP_VRGameMode had been reset to “none”. At this point, the VRCharacter class still existed, so I switched it back in the blueprint, but the VR Preview option was still greyed out. I closed the project, and after opening it back up, the VR Preview option was available, but the Default Pawn Class had been reset to “none” again, and the VRCharacter class is just gone from the C++ Classes folder in the Content Drawer. I can play the map in VR, but since the class doesn’t exist, I can’t move around. I still have all of the code in VSCode for it, but it’s bizarre that it disappeared in the first place.

Has anyone seen or heard of this happening before? Is there a fix for it? I’m going to remake the class so that I can continue with the course, but I’m wary that this will happen in any future projects I create too.

Update: After recreating the VRCharacter class, it worked perfectly for the instance where I recreated it. I specifically made it public as well (in the video, neither public nor private are specifically selected) and it showed up under the C++ Classes folder in the Content Drawer, though it was now under a Public folder. However, when I closed the project and reopened it, the VRCharacter class had seemingly disappeared again. In the explorer, I noticed that there was now a Public and a Private folder under sources, and noticed that VRCharacter.cpp had been moved to the Private folder. VRCharacter.h was still located in the Public folder.
Keeping the .cpp file in Private hides it from the content drawer, so I moved the .cpp file back to Public from the explorer. This lets it show up in the project again, with the annoying caveat that I have to make sure to hit the Live Coding button when the project starts up to make it show up - VRCharacter doesn’t show up just by simply opening the project. This also means that I have to manually set the Default Pawn Class in BP_VRGameMode back to VRCharacter from None, because it doesn’t see that it exists on project startup and defaults back to none. I also noticed, since I moved the .cpp file to a different folder, that I can no longer run a build task in VSCode. Hitting CTRL+Shift+B to open the build tasks simply returns a message of “no build tasks available” or something to that effect.
So it appears that the .cpp file for a C++ class, even when made public upon creation, gets turned private somehow - and this only happened today after importing assets into the project. I made the project and the VRCharacter class yesterday at the time of writing, and opening it today, the class was still there and worked. Only after importing the new map and assets did it have any problems.

1 Like

The best way for importing older UE4 assets to UE5 is create a project in UE4 called Migrator and add the assets to it, then migrate the desired assets into UE5. This technique seems to work better than adding older assets directly into a UE5 project directly.

A lot of the assets, such as the great free paragon assets do not work as intended in UE5 without some modification so be careful what you bring in directly.

I’m glad you got the issue sorted.

Good to know about that for migration in the future.

The issue technically still isn’t completely sorted. Turns out the .cpp file is supposed to be in the private folder regardless of if it’s public or not. I had to regenerate the project files through Unreal, and that’s what made the class consistently show up when opening the project. However, regenerating the project files was theoretically supposed to fix the build tasks in VSCode as well, but right now VSCode still isn’t letting me run a build task (hopefully just for this project; I haven’t had time to look but I’m assuming that it’s only broken for this project).

Update: I opened a separate project and opened VSCode through the Tools menu in UE5, and confirmed that build tasks are available for that project. Normally I’ve been opening VSCode by finding the files themselves and double-clicking them, or I open VSCode and the file is already there since that’s what I was last working on. So, I tried opening VSCode through the Tools menu for this project, and the build tasks are magically there again.
I’m still new enough that I don’t understand all of the nuances with UE5 and C++, so I’m guessing that by opening VSCode outside of UE5, I was loading a cached version that didn’t have any build tasks and opening it from UE5 forced it to update. Or something like that. Anyhow, it appears I’m back in business.

1 Like

The location of the C++ file is dependent on what you select when you create the class - private to go in the private folder, public for the public folder.
If neither Public or Private is set on creation will default to in the source/projectname folder for both cpp and h files. You can add to a sub-folder (bug in UE - you need to modify the CPP file include path for the header and rebuild) which also works.

This should not affect what you’re doing however.

The regenerating of project files is a thing you have to use regardless of editor - I myself use rider and occasionally have to do this.

As for order of opening, I usually open my editor and select the file before launching the editor. The regeneration may show an older file setup but it should update when you open the editor.

I hope this helps.

All of that sounds good - are you certain that’s how the public and private folders/classes work though? I had specifically made my class public (clicking “public” from the public/private options, not leaving public/private unselected) and it made the .cpp class file private regardless. A person I talked to on the Unreal Engine Subreddit also mentioned that .cpp files are private and .h files are public, regardless of what you select between public/private. Has it perhaps changed with UE5?

1 Like

Yes, that is correct behaviour. The header contains the access levels - truthfully where they go doesn’t matter. It always confused me that public classes’ cpp files were put into private. That made no sense to me but ultimately, the location doesn’t matter. It’s all about how the methods are declared in the header file and which section they are in, unless Unreal needs them to be public or private and handles them being in folders - that is actually a genuine possibility. In regular C++, it wouldn’t matter at all.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms