Changing type of component results in crash on launch?

I created an AActor subclass in C++ that has a default UStaticMeshComponent subobject property:


I then created a BP based on this class and set the static mesh of that component in the editor:


If I now change the type of that property to anything else (UArrowComponent, UDestructibleComponent, etc…) the editor crashes at launch, or at latest when I try to open the BP. Is this normal? Once I create a BP based on a C++ class, I can’t change that class’ interface anymore?

That happened to me also.You simply cant change that property while you’re having blueprinted version of the class.

So what’s the proper way to do these things then? Because apparently referencing assets from code is bad. For instance in the FPS template, the ACharacter class has a ProjectileClass property that is set in the editor to a BP. This BP is based on a Projectile class that defines the mesh and collision components. But what if I now want to change the collision to a capsule for instance? Would I have to delete the entire the entire Projectile BP, change the base class and recreate the BP from scratch? I hope there is a way around that.

Aren’t BPs like “visual subclasses”? If I change a super class, the changes should normally be forwarded to any child class.

Well if you think about it,it makes sense.Because BPs are compiled into classes at the background and it derives from your class,when you change your class definition it crashes because of the obvious.Say,your collision mesh is Box when you compile your class and you create the blueprint it’s based on your class.But when you change it to Capsule and when your Blueprint tries to map its Box component to Capsule it simply throws exception.A way around for this simply determining your collision mesh at the start .Or dont use properties from C++,for example you can access static mesh component during run time.Just create your blueprint and you can reference it from C++.Check my post here
https://forums.unrealengine.com/showthread.php?1940-C-Getting-Components-from-BluePrint-using-C&p=11371#post11371

Obviously nothing should crash, so there is a bug there, I will file a report. Have you tried just removing the StaticMeshComponent and adding a new component (with a new name)? Does that still crash?

There is nothing ‘wrong’ with referencing assets directly from C++, we just find it a bit easier to use a BP because that way you get a nice mesh picker, allow artists to change it etc.

It’s great to hear, that it’s not supposed to crash. I was worried, that I had to rethink my design approach to UE4 and I was doing it wrong. With “nothing should crash”, do you mean that it should instead show an error, or should it just work that way I thought it would?

I created a simple project demonstrating the issue: Mega Link
This is simply the FPS template with an added class CrashingActorSuperClass that defines a UStaticMeshComponent property called MainMesh. Additionally there is a BP_CrashingActor that is based on this class. This compiles and works fine.
Then, if you change the type of the property to, let’s say UDestructibleComponent (both in the .h and .cpp), recompile, reopen the editor, it will crash when you try to open BP_CrashingActor. This is the crash dump: Pastebin

I did some additional experiments. Changing the type of the property and at the same time changing its name (the string in CreateDefaultSubobject, not the variable name) fixes the crashing. But now the BP is loaded incorrectly. It still displays the old name in the Components outliner and selecting it displays none of its properties.

I get a similar crash when dealing with c++.

Let’s say, for instance, I have a c++ class with a default subobject UStaticMeshComponent, with the name “Building Mesh”. Place the class in a level, save the map. The static mesh is upgraded to a skeletal mesh for some animations. Now change that subobject to a USkeletalMeshComponent (with the same name.) The editor doesn’t crash on load, but opening the level will cause a crash.

Changing the default subobject name to, say, “Building Mesh (skel)” fixes it.

I just tried to reproduce this issue to see if this has since been fixed. Hopefully I wasn’t missing anything (had a UStaticMeshComponent property, set the mesh in the blueprint, changed it to a UArrowComponent, relaunched/opened the blueprint).

I was unable to get it to happen for me with the latest code. So if you still have github access and can pull main, hopefully it won’t happen anymore. Be sure to let us know if you still see it though.

Hi Mike,

Good to hear. I’m preparing for some exams next week and don’t have much time for UE currently. I’ll post again here once I was able to test this. Thanks!

I have custom mest component type… I cannot switch inherited component type to static mesh component. Why? No properties are conflicting!!