Hello my fellow enthousiasts,
_
I have a Pickup Actor which retrieves all available pickup item data through a DataTable.
In the constructor I retrieve this DataTable:
static ConstructorHelpers::FObjectFinder<UDataTable> PickupItemInfoObject(TEXT("/Script/Engine.DataTable'/Game/Inventory/ItemData/PickupItemInfo_Table.PickupItemInfo_Table'"));
if(PickupItemInfoObject.Succeeded()){
PickupItemInfoTable = PickupItemInfoObject.Object;
}
In BeginPlay I setup the Pickup Actor with the DataTable info:
if(HasAuthority()){
if(PickupItemInfoTable){
FPickupItemInfo* PickupItemInfo = PickupItemInfoTable->FindRow<FPickupItemInfo> (FName(ItemRowName.ToString()),FString(TEXT("FPickupItemInfo")), true);
if(PickupItemInfo){
PickupName = PickupItemInfo->PickupName;
MeshComponent->SetStaticMesh(PickupItemInfo->PickupMesh);
SetActorRelativeScale3D(FVector(PickupItemInfo->PickupMeshScale,PickupItemInfo->PickupMeshScale,PickupItemInfo->PickupMeshScale));
bShowPickupName = PickupItemInfo->ShowPickupName;
MeshComponent->SetRelativeLocation(PickupItemInfo->PickupMeshOffset);
}
}
}
This works at runtime, but this unfortunately doesn’t make the StaticMesh appear in the Viewport, which will make it verry difficult to place these Pickup props in the map, since I can only see them at runtime.
The DataTable is retrieved in the constructor.
The data is set in BeginPlay since otherwhise I didn’t see anything at all (not even at runtime).
My guess is that it has something to do with the staticMesh itself being… static that is.
But there must be a way to make it so?
Or is my current logic not the right way to handle this?
Should I just copy paste an existing BP_Pickup and change the mesh manually and don’t store it in a UDataTable?
Thanks in advance for any help!
~ Nick