Keep loosing(?) playercontroller

I currently have C++ code for playercontoller that a playercontroller blueprint derives from. It’s setup in gamemode to be default.

Since converting project to 4.18 I have random instances where after I compile my code from what it seems the playercontroller is reverting or not loading. I know this because there should be stuff printed onscreen in the beginplay() area. It works for so long and then I hit PIE and none of the code in the playercontroller runs making me think it’s using another playercontroller.

Closing and re-opening the editor makes it work again usually, however now I’m stuck in some loop. When I close/re-open it runs but not on the current compiled code (has error). If I compile the code and run again I seem to loose the playercontroller and none of the code runs. Then close/re-open editor and playercontroller code runs but not the most recently compiled so has error.

Been trying to fix this error in my code but I can’t get new compiles to take.

Hey there,

Are you compiling from Visual Studio or preforming hot reload from the editor / with the editor open? If you haven’t, please try compiling from Visual Studio to clear out old hot reload .dll files. Additionally, when the BeginPlay() text does not print, can you check the GameMode to see if the Player Controller setting there has been changed?

I’m compiling from Visual Studio. I fixed my bug loop above though by pressing the compile button from the editor next load.

Since then I have been still experiencing intermittent times when I PIE and none of the playercontroller code executes. I’ve tried compiling with the editor button and doesn’t change anything.

I’ve also checked and double checked my gamemode and world settings when this happens. Here are the events:

  • Start up Visual Studio (.sln file launch) then start up editor (or other way around).
  • Mess with code/compile
  • PIE
  • Mess with code/compile
  • PIE
  • Mess with code/compile
  • PIE ---- Now nothing from playercontroller shows up in editor (just blank screen because level is blank)
  • Close Editor/Re-open
  • Compile again
  • PIE works now
  • repeat

Sometimes it takes multiple restarts or shutting down both visual studio and editor for it to start working again.

Just an update right now I loaded up the project I was working on yesterday which I made some code changes that showed up yesterday.

When launching fresh today and I hit PIE it was not showing the most recent changes. Visual Studio said compile was up to date. I pressed the compile button in the editor and then PIE showed the recent changes.

Also sometimes I get a message when launching the program from the editor along the lines of “This program was compiled in an earlier version of unreal would you like to recompile now?”

Could this have something to do with updating a 4.17 version to 4.18?

I can’t say for sure if it is an upgrade issue. Have you been able to reproduce the behavior in a new 4.18 project or a new 4.17 project after upgrading? Additionally, what do you mean by “mess with code”? Can you elaborate on what code changes are being made / what information you’re looking for that is not being updated when you hot reload?

In “messing with code” I’ve been mainly working on building interfaces via widgets in c++. It usually involves changing a number (x/y/width/height) of a few items then recompiling/reloading to see how everything looks.

I also have a directory browser and had to troubleshoot a few things interface wise for that.

This project is completely blank (everything deleted from level) and I only have a gamemode/playercontroller with playercontroller being done in c++. I have created this project to focus and test one singular thing (file browsing with widget interface) which will later be included in my main project. It’s mainly a testing bed for code and so I work by making changes and checking it over and over.

It could be just my head but it also seems to be the longer I let it sit idle the greater chance when I hit play it will be blank. If I alt-tab to something else for awhile then come back and hit play I just Know it’s going to be blank and have to close/restart the editor.

Also it seems every time I start up the editor I need to recompile the code to get the most recent changes showing up.

For example if I have a button with text inside that says “Load”. Then I change it in code to say “Load File” and recompile. If I test in editor and it is blank then close/restart editor if I hit play without recompile it will say “Load” it seems to only show the last played compile. If I recompile then it will say “Load File”

I suppose since this is only code I will try a fresh start and see if that fixes the issue. Super annoying one it is :).

I created a new project and copied all the code over to it had the same problem but found what is happening.
So I was wrong the beginPlay is firing I just had this at the top of my code and didn’t pay attention:

if (IsLocalPlayerController()) {
		if (wLinkerWidget) {

which is checking this:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets") TSubclassOf<class UUserWidget> wLinkerWidget;

Seems every so often wLinkerWidget is not there so it doesn’t run. Repeated compiling doesn’t change this and restarting the editor is the only way to get it back. Not really sure of the solution for this.

Another update. This happened again and I went and checked the playercontroller blueprint (based off my c++ one) and under widgets the linker widget dropdown was set to none. Somehow it is getting changed on it’s own.

Happened couple times more. Can confirm the widget select was set to none. Restarting or changing the dropdown back fixes it.

Hey Mctittles-

After your latest comments, I found that TSubclassOf variable values are reset on hot reload - a report for this issue has been logged here Unreal Engine Issues and Bug Tracker (UE-51994) . You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.

Cheers

Hi , it’s been almost a year and this bug has now been marked as “Cannot Reproduce” despite 42 upvotes, your confirmation and affecting four versions of the engine.

Will this ever be fixed?

NOT fixed as of 4.21.1. I don’t know if it was actually fixed in 4.21 and it was re-introduced in 4.21.1, but it is definitely still recurring.

Specifically, I have the following declared in a class derived from UActorComponent:

UPROPERTY(EditDefaultsOnly, Category = "Setup")
TSubclassOf<AProjectile> ProjectileBlueprint;

Projectile Blueprint is reset to None every time the editor is re-opened or Hot Reloaded.

I’m experiencing same issues as PY20-GX. I change the pointer in my blueprint and save. When I restart the editor it is back to nullptr.

Additionally, I see other UPROPERTYs resetting, too. Floats and int32s to be specific.

This is all from a UActorComponent.

I have fixed the problem of blueprint properties resetting. I deleted all generated files and rebuilt my project from scratch. Everything has been working flawlessly for the last couple days. Specifically, I deleted

.vs
Binaries
Intermediate
Saved
*.sln

Then right-click the .uproject and select “Generate Visual Studio project files”. Then open the project and recompile and redo lighting. When first opening Visual Studio, it will also rebuild its own database stuff. After it’s all done, things just worked for me. Yay!

I’m using the latest Unreal editor (as of this writing), version 4.21.2.

ANd, no, it does not work.

Can epic games please prioritize fixing fundamental bugs in the editor like this instead of constantly just adding new features to unreal engine? There is a stream of hundreds of bugs that crop up in cases like this and they aren’t even acknowledged. I have just started using unreal engine and have already encountered this bug among others in 4.25.3. Reading through the bugs on the forums it seems that the unreal engine devs don’t really want to acknowledge these as bugs because they might seem too hard or boring to fix. I don’t want you to give up on them though. The engine still has a lot of potential to work with C++ it just needs a bit more time in that area. They are not just going to disappear as new features are added.

how do I delete generated files? I tried generating my solution again but it didn’t make a difference