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.