Wrekk
(Wrekk)
July 4, 2015, 6:51pm
19
Well you should spawn the Item in world (create a instance of it) and then store it in the array.
Using a Server RPC to add the item server side, and have it replicated to client.
Now in my opinion having a inventory with references to actors for a networked game.
Is not something i see as a generally good idea, if you think about having a lot of players.
And all of them are carrying a bunch of items, that are referenced and must be located some where in the world but hidden or something as they are in a backpack or what have you.
A struct with a item id defining the type of item and filling in the data as needed.
e.g: Icons for UI using the ID.
Also have a look at conditonal replication, for my players inventory my condition is to Owner only like this.
// replicating this ONLY to owning player.
DOREPLIFETIME_CONDITION(AMyPlayerClass, InventoryContainer, COND_OwnerOnly);
This will save you a lot of badwidth.
Now am not saying its the only way to do it and depending on your game design so 4th but this is preferred approach by many.
I’d really like to avoid having all items spawned in the world, and a struct is not something I see as a viable option unless I can make my item subclasses inherit from the base item struct (which I don’t think is possible, or is it?).
And thanks for the tip, I’ll make sure to put it to good use.