Changing component types causes corrupted BP

UME_CharacterCollisionComponent derives from UCapsuleComponent
UME_CharacterMovementComponent derives from UCharacterMovementComponent

I’m not sure what you mean by ‘inside the constructor’ ? As far as I was aware, the only way to use the SetDefaultSubObjectClass() method was in the way I did it there. Anywhere else in the constructor gives me a compile error - “Subobject class setup is only allowed in base class constructor call (in the initialization list)”

After testing SetDefaultSubobjectClass I am seeing the expected result.

AMyCharacter2::AMyCharacter2(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer
		.SetDefaultSubobjectClass<UMyCapsuleComponent>(ACharacter::CapsuleComponentName)
		.SetDefaultSubobjectClass<UMyCharacterMovementComponent>(ACharacter::CharacterMovementComponentName))

When this is added to my custom character class (MyCharacter.h), the blueprint based on the class updates the component that is being used appropriately.

Our setup is identical then … this is my result

The blueprint shows that the correct class is assigned to ‘CharacterMovement’ (my child movement component), but it is not creating an instance of that component class

Here is the result when I create an entirely new blueprint based on the same parent class as the above old blueprint. As you can see, an instance of the movement component was created and the properties are available.

Can you provide the rest of your custom character movement class? The class I tested with was empty other than default boilerplate code and the details panel is fully accessable.

Additionally, can you try creating a new, empty CharacterMovementComponent class and use that instead and let me know if you get the same results.

Here is the header for my custom movement component, there’s not much to it.

The only thing I can think of that might have caused this, is that I am using class redirects ( I renamed the character movement class, and redirected from what it was previously called).

I don’t know if that’s helpful information or what, but at this point I think I’m just gonna recreate the blueprint and move on :slight_smile:

As a rule of thumb, I generally avoid putting too much work into blueprints and try to keep most of my code and properties C++ side. Occurrences like these kind of hammer home the logic in that.

Hi, I just had this happen to me on 4.13.2 when I changed from UHierarchicalInstancedStaticMeshComponent to UInstancedStaticMeshComponent. BP that used this component are corrupted and need to be recreated.

Sad thing is that this still happens even in UE 5

1 Like

Yep, still regularly happens in 5.2.

yep. I needed to change my component classes for my cars. Each car is composed from like hundred of parts. Now my project can be binned, because I am UNABLE to switch component class in C++. Amazing…

1 Like

edit: managed to fix it, in my case i just needed to override the serialize method and use the parent serialization function call (UPrimitiveComponent::Serialize)