Loading UBlueprint or Baseclass in Constructor

anonymous_user_537a337d
Tue, 28 Sep 2021 22:31:36 +0000
Asset Creation

Currently I am loading weapons in the constructor using USkeletalMeshComponent’s. But I would like to change it to UBlueprint or prehaps the baseclass itself using FClassFinder/FObjectFinder. Unfortunately I am unable to get the object to display. Can someone provide a link or code that shows how that is done?

static ConstructorHelpers::FObjectFinder<USkeletalMesh> WeaponSkeletalMesh(*WeaponName);
if (WeaponSkeletalMesh.Succeeded())
{
	USkeletalMeshComponent* meshComp = CreateDefaultSubobject<USkeletalMeshComponent>(ARvBCharacter::RightWeaponName);

	meshComp->SetRelativeRotation(RightRotation);
	meshComp->SetRelativeLocation(RightLocation);
	meshComp->SetRelativeScale3D(RightScale);

	meshComp->SetSkeletalMeshWithoutResettingAnimation(WeaponSkeletalMesh.Object);
	//meshComp->SetupAttachment(GetMesh(), ARvBCharacter::RightSocketName);
	meshComp->AttachToComponent(GetMesh(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), ARvBCharacter::RightSocketName);
}

2 posts - 1 participant