I tried to run the DamageTaken() function in the HealthComponent in lecture “Applying Damage 136” when I started to get a crash that was typical for referencing a null pointer. So I started commenting out code fragments until the game would stop crashing. I figured out that it was the reference to the static mesh component of BP_Projectile that was missing. When I look at BP_Projectile in the content browser, it clearly shows the Bullet Mesh
but when I open the full blueprint editor, the viewport section doesn’t show the projectile mesh. What’s more: I added the selection for the static mesh component using a UPROPERTY(EditDefaultsOnly, Category = “Combat”) in the C++ class. But when I look at the derived blueprint actor from my C++ class, that section doesn’t show up. The hierarchy of the components clearly shows that there is a static mesh component, but the UPROPERTY is invisible and cannot be set to anything and the mesh doesn’t appear in the viewport.
I didn’t have any fatal crashes before this and I always made sure to rebuild the entire project from VSCode after every lecture with the editor closed. I am baffled how this could even happen in the first place, but I am not really mad anymore since I’ve already made the experience that Unreal likes to randomly break things for some reason.
So my current strategy is to remake the BP_Projectile from the C++ Class and reset all the properties (if that will be possible then), which should be no issue, since all the code for those components to exist is specified in the C++ code of the AProjectile constructor.
Header file:
My question is:
How did this happen? Did I set some property incorrectly? Did I compile incorrectly? And also:
Do changes to the C++ class of AProjectile not get dynamically passed on to the derived BP_Projectile blueprint? If I add another component through C++ in Projectile.cpp, should that component not show up in the outliner of the derived BP_Projectile blueprint after compiling? How can it be that my C++ code is all there, I keep recompiling it, yet the StaticMeshComponent property seems to be missing from the BP_Blueprint and cannot be set? Is the broken blueprint preventing the updates in C++ from reaching the derived BP_blueprint somehow?