Can't edit Character Movement Component when using SetDefaultSubobjectClass

I recently upgraded from 4.18 to 4.22.3 and found that I can no longer edit my custom Character Movement Component on my custom character class. I originally followed Rama’s instructions here to have my PFCharacter class use my UPFCharacterMovementComponent:

APFCharacter::APFCharacter(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer.SetDefaultSubobjectClass<UPFCharacterMovementComponent>(ACharacter::CharacterMovementComponentName))

the result in 4.22.3 is that everything functions perfectly in game based on the values I set before the 4.22.3 upgrade, but when I select the component in editor I can’t edit any properties.

I should note…creating a new non-custom Character results in me being able to edit the non-custom movement component just fine.

Yikes! Any ideas?

Quick work around update … opened up my character in the Property Matrix on a whim and can see properties in there! Seems to be a property visibility issue in the blueprint editor view.

The weirdness continues…I can also edit character movement component properties on my character placed in the level.

As this is still the case in UE5, the solution for this problem is, that you also need to declare a variable with your new movement component and assign it:
In you header of your character, add something like

class AMyCharacter : public ACharacter
{
    //....
   UPROPERTY(BlueprintReadOnly, VisibleAnyhwere)
   TObjectPtr<UMyMovementComponent> MyMovementComponent;
}

And in the constructor add:

AMyCharacter::AMyCharacter(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<UMyMovementComponent>(ACharacter::CharacterMovementComponentName))
{
   MyMovementComponent = Cast<UMyMovementComponent>(GetCharacterMovement());
}

The component will then show up as MyMovementComponent in the Blueprint Editor as it uses the new variable instead of the one defined in ACharacter.

1 Like