Hey! I have a couple of objects that I spawn at runtime and attach to my character. It works in the editor, but if I try to package the project for playtesting, they don’t spawn, and if I try to do anything with it (I.E attach a weapon to the player’s hand) the game crashes.
UObject* WeaponSpawn = Cast<UObject>(StaticLoadObject(UObject::StaticClass(), NULL, TEXT("/Game/Equipment/Blueprints/BaseWeaponBP.BaseWeaponBP")));
UBlueprint* WeaponGenBP = Cast<UBlueprint>(WeaponSpawn);
//WeaponSpawn = NULL;
if (WeaponSpawn)
{
//WeaponSpawn = WeaponBlueprint.Object->GeneratedClass;
UClass* SpawnClass = WeaponSpawn->StaticClass();
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = this;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
CurrentWeapon = GetWorld()->SpawnActor<ATribesmenWeapon>(WeaponGenBP->GeneratedClass, GetActorLocation(), GetActorRotation(), SpawnParams);
if (CurrentWeapon)
{
const USkeletalMeshSocket* socket = GetMesh()->GetSocketByName(FName("SheathSocket1"));
socket->AttachActor(CurrentWeapon, GetMesh());
}
}
What am I doing wrong?