Custom CMC Not Appearing in Blueprint

I created a custom character movement component and I edited the constructor of the C++ character class to look like this:

AMyProjectCharacter::AMyProjectCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer.SetDefaultSubobjectClass(ACharacter::CharacterMovementComponentName))

But when I go to my character blueprint and try to implement the custom CMC, it’s not there. Why would this be?

I believe the ObjectInitializer is deprecated and only still used with the widget system.
Try the following in the constructor:

CreateDefaultSubobject<AYourComponentClass>(TEXT("Your Component"));

This is the way I normally create things. This is also the way required for components to show up on the blueprint component panel. Please test if this replaces the original component or adds a second one though.

You need to pass the class as a template parameter in SetDefaultSubobjectClass like so:
ObjectInitializer.SetDefaultSubobjectclass<UMyProjectChacterMovementComponent>(CharacterMovementComponentName)

In the .cpp file?

Yeah in the constructor, like you are already doing, just add the template parameter

Is this what you meant? Because it still doesn’t work.

AMyProjectCharacter::AMyProjectCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer.SetDefaultSubobjectClass(CharacterMovementComponentName))

This is how I’m using it atm, with no issues

That also doesn’t work. It says it can’t substitute non-type template argument UModularBodyComponent for type template parameter T.

I think I figured something out. In the header file, right after

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=Movement) UCustomCharacterMovementComponent* CustomCharacterMovementComponent;

it says “Unchanged in assets”. I think I need to properly set that in the Unreal Editor, but I don’t know how.

The Modular body component was from my project, so don’t worry about it, you can remove that line
If you use that constructor to set the class of a subobject, the subobject will be of the new class, in blueprint at least. That means that the original Character Movement component in your blueprint will be of the selected class, you don’t need a new variable of the custom type. If you do want to cache it for C++ access, then you need to cast the already existing character movement component to your class and save it in CustomCharacterMovementComponent. But you can use the templated version of GetCharacterMovement in C++ to get it cast to your custom class

Also, Edit specifiers are of no use for object instance properties, since you can’t assign an instance in a blueprint

But if you select the already existing movement component in your blueprint you should be able to see your custom component properties, just as you would expect

It looks like the only CMC-related thing I can put in my blueprint is Cast To CharacterMovementComponent. Is that normal?

In my character blueprint, under components, it lists the default CMC instead of my custom one. It says it’s inherited from C++. How do I change it?