Daily Unreal Column #21 - Prevent component creation in parent class
Following up on yesterday's Daily Unreal Column, today I want to present a way to use object initializer to prevent the parent class from creating a component.
Imagine you are making a game where you want to use ACharacter
as your base class. However, you do not want to use one of it’s components that is created by default, for example, a CMC (Character Movement Component). You can prevent this component from being created by using object initializer in your subclass constructor function like this:
AMyCharacter::AMyCharacter(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.DoNotCreateDefaultSubobject(
ACharacter::CharacterMovementComponentName)
{}