How do we create (override) the default character movement component using the default constructor on 4.18, instead of Super(ObjectInitializer.SetDefaultSubobjectClass(ACharacter::CharacterMovementComponentName))
Hey there, i searched online and found this:
In my pawn class, I create my custom movement component in my constructor
PawnMovementComponent = CreateDefaultSubobject(TEXT("PawnMovement")); PawnMovementComponent->SetUpdatedComponent(CollisionComponent);
and override this...
virtual UPawnMovementComponent* GetMovementComponent() const override { return PawnMovementComponent; }
Worst case you can use the old FObjectInitializer
Thank you! That is exaclty what i need
Works great.
Good to know
How would I then go about destroying the default movement component?
Because when I do this, I now have 2 movement components on my character. And I can’t seem to access the default one to destroy it become I have overriden GetMovementComponent()
k I just found a solution. I call the base classess GetMovementComponent specifically
ACharacter::GetMovementComponent()->DestroyComponent();
Scrap that, gives strange results where I recompile an additional movement component gets added until I compile the BP.