In the past week, several times I have had attached actor components randomly break. By break I mean that when you click on them the details panel is completely blank, not that the variables are blank, it just is completely blank. The component then will not work and when you try to use it, it crashes. This initially happened on the player with the attached Skill Tree component. After a long while I was able to fix it by
commenting out the line in the constructor that created it:
SkillTreeComponent = CreateDefaultSubobjectUSkillTree(TEXT("Skill Tree"));
then closing unreal and deleting all folders but the core 4 and reopening to get rid of the broken component, and then uncomment the line and live compile and it came back working. And then literally as I fixed it, the XP component broke, even though I nor anyone else had no touched it any time recently. I tried what I described above over and over and over for over an hour and it would not fix. I needed to find another way. And luckily I did because Thursday night right before trying to make the build, the same exact thing happened to the Health Component on all the enemy's, and again I could not fix it the original way.
I noticed that if I duplicated the broken component, the duplicated one would be perfectly fine (proof I did nothing wrong and it worked fine, just Unreal being Unreal). So at first I thought this was an easy fix, just use the duplicate, but I realized that 1 I could not delete the old broken one as it was attached via C++ code, and 2 the code is connected to the broken one and the new one wouldn't be used. The first thing I tried was similar to the original way I fixed it, I commented out the line that created it:
//XPComponent = CreateDefaultSubobjectUXP_Component(TEXT("XPComponent"));
and rebuilt the project but this time I was going to keep it commented out since it was broken, but I feared removing the component would then remove the duplicate of it, but to my lucky (if you even wanna say I have any good luck at this point) surprise even with the broken component gone, the working duplicate remained. The next step was to get the new component to be used, and I did this by using blueprints (the only way), I went into the construction script graph and I took the variable for the component in code (that is now not created but the code wants to use it), and I set it using the duplicated working component, and this made everything work like normal before it decided to break. Fast forward to an hour ago, right before making the build the exact same thing happened to the health components on the enemies, and I had to go through this entire process for every single one of them.
Below are screenshots show of the broken component, the duplicated working component, and setting the variable via the construction script in blueprints