Hello Everyone,
I want to make an Inventory system for my MMORPG game, so my design was to create an inventory as a dynamic buffer of Entities (Items) in the Server assembly side. I have many different types of items, so each item type is based on a unique collection of components.
My question is I want to create the item entity as normal in server side (without Ghost Component), but maybe the Netcode prevent it and the created Entity seems disposed after creation and don’t need the item to be replicated to all client and I will sync the item stats throw RPCs to the owner client specially item stats do not change frequently it’s only change when do some crafting on it.
Is there any way to do that or even make it a ghost item but only replicate to its owner client?
public struct Inventory : IBufferElementData
{
public Entity Item;
}
public struct ItemStats : IComponentData
{
public int Id;
public FixedString64Bytes Name;
public ItemType Type;
public FixedString64Bytes Sort;
public enum ItemType
{
PhyWeapon,
MagWeapon,
Shield,
.....
}
}
That is what happen when add a normal entity into buffer:
internal BufferLookup<Inventory> inventory;
var item = ECB.CreateEntity();
ECB.AddComponent<ItemStats>(item);
inventory[playerEntity].Add(new Inventory { Item = item });
It gives me Invalid entity inside the buffer.
“Player’s Inventory Component”
“The Item Entity in Entities Hierarchy”
Is my design wrong with ECS? Need to hear from you.
Thanks in advance.