I’m doing an inventory system in my game and when I pick up an actor from the floor the inventory array can either have a pointer to it or if there is another item of the same type it can stack.
The function is called on the server to do the pickup, then the inventory is replicated, and the stacks of each item is replicated as well.
At some point this happens to do the stacking
//all this runs on the server
if (itemToPickup->GetClass() == InventoryArray[i]->GetClass())
{
if (itemToPickup->currentStacks + InventoryArray[i]->currentStacks <= InventoryArray[i]->maxStacks)
{
InventoryArray[i]->currentStacks += itemToPickup->currentStacks;
itemToPickup->Destroy();
return false;
}
Since currentStacks is replicated, it should change on the client machine, as it does, until it gets to 1 to 8 (if I add 1 every time), then it randomly stops replicating and stays the same on the client machine but still goes up on the server machine. I tried to add an OnRep function to the currentStacks and when it didn’t go up the function wasn’t called as well, confirming it didn’t replicate. bReplicated for the item is enabled as well. Any help?