Using custom character movement component *updated - not appearing in editor for my character

Looking through here : https://docs.unrealengine.com/en-US/…nts/index.html

It recommend overriding GetMovementComponent function, and return a custom variable which is pointing at my custom class.

But, I was expecting to set a private variable like CharacterMovement=MyCustomMovement.

Even under the declaration GetCharacterMovement() is this:


/** Name of the CharacterMovement component. Use this name if you want to use a different class (with ObjectInitializer.SetDefaultSubobjectClass). */
static FName CharacterMovementComponentName;

Does this mean I can set CharacterMovementComponentName=‘MyCustomMovement’ inside MyCustomCharacter header file?

Which is the best/correct option here?

  1. Custom variable, override GetMovementComponent
  2. Set CharacterMovement=CustomMovement variable in my CustomCharacter header file
  3. Set CharacterMovementComponentName=‘MyCustomMovement’ variable in my CustomCharacter header file

I’m comfortable with the old UScript (though it has been many years and perhaps I’ve forgotten how it works), and langauges in general, but I’m new to C++, and I just want to make sure I’m approaching this correctly.

Cheers

Ive followed one of the tutorials, and now have:

MyCharacter.cpp:


AMyCustomCharacter::AMyCustomCharacter(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<UMyCustomMovementComponent>(AMyCustomCharacter::CharacterMovementComponentName))
{
//code
}

And then custom movement component stuff:
UMyCustomMovementComponent.h


#include "CoreMinimal.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "WPMovementComponent.generated.h"

/**
*
*/
UCLASS()
class MyGame_API UMyCustomMovementComponent : public UCharacterMovementComponent
{
GENERATED_UCLASS_BODY()

public :
virtual bool CanAttemptJump() const override;
virtual bool DoJump(bool bReplayingMoves) override;
};

UMyCustomMovementComponent.cpp


UMyCustomMovementComponent::UMyCustomMovementComponent(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{

}

Everything builds fine. I can put prints and break points in my custom character - and can see that is being used from editor.
Im using the ThirdPersonExample template.
In the editor when I open my ThirdPersonCharacter - I can see it extends from MyCustomCharacter. But its MovementComponent is not using mine, its still using default.

Have I missed something obvious ?