Hello,
I’m trying to loot an Item from the world, add it to the inventory array of item pointers… All is good it replicates I can spawn them and loot them and they keep replicating.
If I however call LootedItem->Destroy(); everything goes to ■■■■… Obviously my pointer goes to null, so bye bye item in the inventory…
I try and fix this by creating a copy if the Item before calling destroy and adding that to my inventory…
Looting and adding item to inventory:
Item* ItemCopy = DuplicateObject(LootedItem, ItemOwner);
PlayersInventory[FirstFreeSlot] = ItemCopy;
LootedItem->Destroy();
all is well again, it replicates from the servers copy of inventory to the owning clients inventory. I spawn it again, everything fine both server and client have no Item in inventory and I can see the item in the world on every client.
However when I loot the spawned item again, It only shows up on the servers inventory, the client has nothing in it’s inventory.
Spawning the item in the world
Item* SpawnedItem = GetWorld()->SpawnActor<ALootable>(ItemToSpawn->GetClass(), SpawnLocation, SpawnRotation);
Does anyone have an idea what is going wrong? or some way to get this replication to work?