I have some Actor. This actor represents all the items in my game that can be picked up.
class APickupActor: public AActor
In the constructor I use
static ConstructorHelpers::FObjectFinder<UStaticMesh> DefaultSphereVisualAsset(TEXT("/Game/Defaults/BasicSphere.BasicSphere")); ... m_meshComponent->SetStaticMesh(DefaultSphereVisualAsset.Object);
So that it has some default mesh, in case something breaks later on. Hopefully no one ever sees this mesh.
At some point I instantiate this dynamically created actor. Then set a value on it
Inside SetItem(item), I go and find out everything extra this should have on it, perhaps add some more components, and update it’s mesh.
// This queries a data asset/json/file for what the mesh should be. // For example, newMeshString = "/Game/Items/GoldCoin.GoldCoin" FString newMeshString = ItemDB.GetMeshString(item); auto newMesh = Cast<UStaticMesh>(StaticLoadObject(UStaticMesh::StaticClass(), NULL, TEXT(newMeshString))); m_meshComponent->SetStaticMesh(newMesh);
ItemDB is basically powered by an external json that will eventually have some mod-ability support for people to make new items.
This all works just fine for now.
But then I see posts like this
"The reason is that once you start cooking your game, asset references defined in this way are completely invisible to the cooker. Cooking only cares about assets you’re actually using, otherwise you’d end up shipping cooked games with piles of data that isn’t actually used anywhere. "
Is this going to be a problem for me or is there a better way of doing this?
Is there a way to make sure I am cooking in the relevant assets? Do I need to make a dummy object that just loads all my meshes(and other assets somewhere)?