Suspected problem with live coding?

I’m new to UE, so it’s probably just me, but here’s what I spent several hours trying to fix last night and today:

I have mostly C++ files, no blueprints, had lots of working code, then try to make some small changes. Unreal begins crashing, so I walk the changes backward. Unreal keeps crashing. I take out more code. Unreal keeps crashing. Long story short, I eventually resort to taking massive chunks of code completely out until I am left with blank classes.

Unreal magically compiles successfully again.

But then - I begin adding in code one line at a time, recompiling, adding a bit more, recompiling, etc. UNTIL ALL OF MY CODE IS COMPLETELY BACK WITH NO CHANGES MADE. It’s as if Unreal somehow had corrupted files and wasn’t picking up the actual changes I was making before until I gutted everything for it to realize it needed to update the classes? I don’t know. This is bizarre to me.

I am using Visual Studio and Live Coding. I’ve seen some people say that it’s better to build from within Visual Studio, but whenever I try to do that, I get loads of errors. It only works if I do it from within Unreal with the hot load button or whatever. I have an older version of VS installed, so maybe that’s why.

Why is this happening though? This is insanely annoying and cost me hours of trouble-shooting.

Everybody recommended RIDER, so i got it and never looked back at ms IDE products.

Crashing in unreal is quite complicated, it is because it tries to run code in editor, load order and all that stuff that goes against natural order of C++. :smiley:

Usually i get crashes when i do minor changes to some function that renders it unusable (wrong pointer or giving wrong index in array etc,).

When you live compile it and click blueprint or widget with such code , unreal loves to crash.

So use backups like git or pack whole project every major change, or at least daily.

I did few mess up (usually while cleaning code and moving stuff around) so having bacups saved me more than once.

As to live coding:

  • it is fine most of the time, but then you do some major change and it will stop working. Once i lost like week trying to fix some function, then after fixing it and my fixes never worked, i found out that live coding compiles stuff but that new code never is updated in unreal. But during that week i really ironed out all bugs in that function.
  • sometimes when msvc starts (like when i double click CPP function in bleprints and unreal runs MSVC, while i code all in rider). Whole project gets messed up. To fix it either rebuild solution/project, or delete project solution and recreate it.

And yes unreal C++ is annoying, one bad index to array or wrong pointer and boom. However it is much better than doing functions in blueprints. And best way to code is to mix BPs and CPP. Big code chunks like game logic, enemy AI on higher level (like what to do), etc. is best done in c++, then rest also in C++ but as separate functions to be used from BPs.

ps.
chat GPT is great to ask questions like: “how do i create persistent module that can be used in game instance”. It gives mostly good ideas with some boilerplate code to start with.

Thanks. I’ll check out Rider.

I did manage to have this problem creep up again and figured out a solution. What seems to happen is that I will make a small change, Unreal will crash, I undo that change, but Unreal continues to crash anyway. The solution for me was to exit everything and delete the Win64 folder under /Binaries/ then boot everything back up. Then it magically runs just fine. My guess is that Unreal is building my code into the binaries, but when it crashes, it loses sight of what files need to be updated. So, when it boots back up and I press recompile, it never recompiles the new cpp files I reverted because it thinks it doesn’t have to.

The most critical thing here is being able to recognize when this bug is happening. After a crash, it may just be good practice to delete the Win64 folder every time to avoid hours of bug-hunting for a bug that isn’t actually there (since it’s Unreal’s fault).

That binary folder is mess left by visual studio. Yes this is causing crashes because it was not recompiled.

If you kill solution, then manually recreate it, and then build solution, it will recompile everything.

But for me rider works better, no need to clean solution and recompile.
However live coding is not 100% reliable, it mostly works.
But then week trying to fix bugs because i did not realized live coding did not update my code. :smiley:

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