NULL CharacterMovement component when switching from custom back to default

NULL CharacterMovement component when switching from custom back to default

Build Type: Binary

Build Version: Version: 4.17.2-3658906+++UE4+Release-4.17

When using a custom CharacterMovementComponent for the ACharacter class, downgrading to a default CharacterMovementComponent later will break existing blueprints that use the character. After switcing up the constructor arguments and reloading the project, the character blueprints will have a NULL MovementComponent that can not be fixed (since it’s a private, inherited component).

Repro steps:

  • Start with ShooterGame template project
  • View the PlayerPawn blueprint in the editor and notice how it has a valid CharacterMovementComponent
  • Edit the source code for AShooterCharacter::AShooterCharacter:

Change this code:

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

To this:

AShooterCharacter::AShooterCharacter(const FObjectInitializer& ObjectInitializer)
{

This code change should make the ShooterCharacter use the standard UCharacterMovementComponent instead of the derived UShooterCharacterMovement

  • Compile the code and go back to the editor
  • View the PlayerPawn blueprint and notice that it still has a valid CharacterMovementComponent
  • Close the editor
  • Reopen the project in the editor
  • View the PlayerPawn blueprint – It doesn’t have a CharacterMovementComponent!
  • Run the game – It crashes due to NULL component
  • These constructor initializers also produce a NULL movement component:
: Super(ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass(ACharacter::CharacterMovementComponentName))
  • Note that, while the PlayerPawn blueprint is in its bugged state, you can create a new blueprint that uses the ShooterCharacter as its parent. This new blueprint will have a valid, non-null movement component.

1 Like

This needs to be fixed. This has been frustrating me for the past 2 hours, glad someone else has found this.

I have the same problem, Did you solve it?

I solved it by redirecting
[CoreRedirects]
+ClassRedirects=(OldName=“Your custom movementcomponent”,NewName=“You new movementcomponent”)