Hi guys, I’m failing pretty hard (and feeling bad about it :() at Unregistering the UCharacterMovementComponent from the default character from the engine’s template and Registering MyUCharacterMovementComponent on it, which is a movement component that inherits from UCharacterMovementComponent and extends it a bit.
What I’ve done (and not sure about) is:
1)Inherits from UCharacterMovementComponent and manually provides it with a constructor (I don’t know if UE likes this though, since a constructor wasn’t provided by it)
UMyCharacterMovementComponent::UMyCharacterMovementComponent()
{
bMoveWithFloor = false;
}
2)include MyUCharacterMovementComponent from the ACustomCharacter c++ and initialize it in the constructor so that it replace the default inherited UCharacterMovementComponent:
ACustomCharacter::ACustomCharacter()
{
//...OTHER STUFF
//...
GetCharacterMovement()->DestroyComponent();
GetCharacterMovement()->SetActive(false);
NewMovementComponent = CreateDefaultSubobject<UMyCharacterMovementComponent>(TEXT("NewMovementComponent"));
NewMovementComponent->UpdatedComponent = GetCapsuleComponent();
CrouchedEyeHeight = NewMovementComponent->CrouchedHalfHeight * 0.80f; //I copied this line from the UCharacterMovementComponent initialization in the character class, just in case
NewMovementComponent->SetActive(true);
NewMovementComponent->RegisterComponent();
}
This is failing, and if I check in blueprint my character has a valid UMyCharacterMovementComponent but I am getting this error in the log:
Help me pls x_x