I have the following code:
ABaseUnit::ABaseUnit(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
//Create the component
MovementComponent = PCIP.CreateDefaultSubobject<UBaseMovementComponent>(this, TEXT("MovementComponent0"));
//Set it's parameters
//Movement->Something = ? ;
//Add component to actor
AddComponent(FName("MovementComponent0"), false, FTransform(), NULL);
CollisionComponent = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("CollisionComponent0"));
CollisionComponent->InitSphereRadius(35.0f);
CollisionComponent->BodyInstance.bEnableCollision_DEPRECATED = true;
static FName CollisionProfileName(TEXT("Pawn"));
CollisionComponent->SetCollisionProfileName(CollisionProfileName);
CollisionComponent->CanBeCharacterBase = ECB_No;
CollisionComponent->bShouldUpdatePhysicsVolume = true;
AddComponent(FName("CollisionComponent0"), false, FTransform(), NULL);
RootComponent = CollisionComponent;
}
I get this error message when I try to add it to the level in the editor:
D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.1\Engine\Source\Runtime\Engine\Private\LevelActor.cpp(692): Ensure condition failed: PrimComp->IsRegistered()
Components must be registered in order to be used in a ComponentOverlapMulti call. PriComp: CollisionComponent0 TestActor: Default__GameUnit_C
So the probably seems to be the component is not registered. But the documentation says:
ActorComponents are automatically
registered when the owning Actor is
spawned, if they are created as
sub-objects and added to the
Components array in the default
properties of the Actor.
(Unreal Engine のコンポーネント | Unreal Engine 5.3 ドキュメント)
So, why am I getting this error?