I have a player object, inside that player object is the players backpack, when the player dissconnects or dies i want to seperate the backpack from the player, in doing so the backpack needs a network identity, but starting with a network identity on the backpack gives errors since its a child, how can i mitigate this? is it safe to just ignore? and i dont want to spawn the backpack seperatly since its a high CCU game and if its not a child i would have to make clients use extra processing power to align all backpacks and its just not worth it
#Network Identity children
14 messages · Page 1 of 1 (latest)
Hey,
If you dont need exactly that backpack. You can prepare a backpack prefab that includes a NetworkIdentity. When the player dies or disconnects, you can spawn a new backpack from a drop point using NetworkServer.Spawn(), then transfer the player’s items into this new backpack instance.
This avoids issues with nested NetworkIdentity errors and keeps the system clean and performant.
[Server]
void DropBackpack(Vector3 dropPosition, List<Item> items)
{
GameObject droppedBackpack = Instantiate(backpackPrefab, dropPosition, Quaternion.identity);
NetworkServer.Spawn(droppedBackpack);
// Initialize inventory
droppedBackpack.GetComponent<Backpack>().SetItems(items);
}
like this.
alright, i could. another thing is storing items? i have it setup currently so when you store an item it stores as a child of whichever slot you put it in, and puts your item into a SyncList, then other clients when items are added/removed from that list copy it, and having stored items align with the slots every frame wouldnt be viable;
18 slots/items * 200 CCU = 3600 (ontop of having to loop through ALL items which would add a bit more)
inventory is typically SyncDictionary<byte, byte> where key is slot and value is an item ID that clients look up in a static dictionary for art and prefabs and details. You don't put networked objects in the backback, and typically you set SyncMode to "Owner" so all clients aren't being flooded with everyone's inventory.
keyword typically, im making a vr game so it needs to be interactable (why im putting the items inside it), ontop of loot is scattered around so i have to manage players finding and putting scraps and other items inside their backpack.
they need to stay physical items
and spawning and despawning items would be a absolute mess with how many players, items and since its something you access often
i also dont understand why mirror cant handle childed network identitys, seams like the one thing that wouldnt get in the way
here is currently how my inventory works (even with the errors), if there is a better way to sync the data i am very open to ideas but i dont want to change any functionality
i can provide the code for it if needed
You didn't mention VR, and grabbing / equipping isn't the same as inventory (UI slots in a grid of icons)
tagging @old roost to help with VR grabbing
@formal bobcat Can new players join after the games started?
Or once its started, no one else joins, might be a quik solution if so.
yes, there is no "game start", its more like rust so players can join and leave servers at their leisure