I have a blueprint event that is trying to add an item to the characters inventory for a multiplayer game.
The Add Item node has some C++ networking code inside of it.
void UXLInventoryManager::AddItem(TSubclassOf<class AXLItem> item, AActor* owner)
{
if (item && owner && Inventory.Num() < InventorySize)
{
if (GetOwnerRole() == ROLE_Authority)
{
FActorSpawnParameters SpawnInfo;
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
AXLWeapon* NewWeapon = GetWorld()->SpawnActor<AXLWeapon>(item, SpawnInfo);
NewWeapon->SetOwner(owner);
Inventory.Add(NewWeapon);
}
else
{
ServerAddItem(item, owner);
}
}
else
{
UE_LOG(XLLog, Log, TEXT("Unable to equip item"));
}
}
bool UXLInventoryManager::ServerAddItem_Validate(TSubclassOf<class AXLItem> item, AActor* owner)
{
return true;
}
void UXLInventoryManager::ServerAddItem_Implementation(TSubclassOf<class AXLItem> item, AActor* owner)
{
AddItem(item, owner);
}
On the server, it correctly adds the item and then continues on to call the Destroy event.
However on clients, it runs the Add Item node but doesn’t continue on to call the Destroy event.
