I have a replication issue that I can not figure out. Worse, I may be trying to do something that can’t be done.
The good news is that I have a basic inventory system that replicates UObject just fine. I have subclassed my base item (UItemBase) to extend functionality for each type of item I have. These items get replicated to and from my UInventoryComponent (UActorComponent) which keeps a TArray of these basic items. Using GetLifetimeReplicatedProps() and ReplicateSubobjects() this works perfectly.
The problem starts when I decided that I wanted one of my items to also contain an inventory. I subclassed UItemBase to create a UBackpackItem. The backpack item needs to keep an inventory, so I created an instance of UInventoryComponent to keep an inventory of my UItemBase items. While I can get the UBackpackItem to replicate, I am unable to get the inventory within it to replicate. Is it possible to replicate nested items like I am trying to do?
My UInventoryComponent knows how to replicate its subobjects since I use this same component in other places. Within my UBackpackItem I have my UInventoryComponent property set to Replicate. I also have a DOREPLIFETIME entry for the UInvnetoryComponent I am trying to replicate. I am not using ReplicateSubobjects in the backpack since UInventoryCompnent should be responsible for its subobjects.
It seems that creating the UInventoryComponent inside of a UItemBase (UObject) won’t allow subobjects to replicate. Any ideas?
I guess I can fall back and use an Actor base for my Backpack, but I was really trying to keep all my inventory items as UObject. However, my game does need to be able to nest inventories within inventories.
Hair.Pulling.Out.