给character添加组件

void AAnimCppCharacter::AttachComponent(const FString classType, const FString componentShowName, const FName socketName)
{
    UClass *pClass = FindObject(ANY_PACKAGE, *classType);
    USceneComponent *pComponent = NewObject(this, pClass, FName(*componentShowName));
    FAttachmentTransformRules rule(EAttachmentRule::KeepRelative, false);
    pComponent->AttachToComponent(RootComponent, rule, socketName);
    pComponent->RegisterComponent();
}

你可能感兴趣的:(给character添加组件)