I have an inventory system inside a component, I’m setting up the drop logic for items but it doesn’t work for clients unless I run it on the server and I’m not sure why. This wouldn’t have been a problem except I need to update the client’s hud and I can’t access that if this code is being run on the server.
You should absolutely want to run the logic on the server, for pretty much anything you do
The server should have the authority, the client is just there to request things, which the server can even reject
Having multiple sources of truth is never good and can lead to very hard to track problems
I’m not sure how you’ve set up your inventory, but the client should only ask to drop an item, then the server will drop it, replicate any changes, and the client should react to the replicated changes
In some cases, games introduce some form of prediction for certain actions, so that the client can predictively perform them while waiting for the server to also perform them, so that the game feels snappy for the player. Then if the server’s action contradicts what the client did predictively, then the client corrects itself to the received actual data, otherwise no correction should be needed and the game should feel very responsive. However this is quite an advanced topic, and I don’t recommend attempting unless you’re very confident with unreal’s networking, and potentially C++.
In your case, I would probably move some of the logic, for example updating the hot bar, to doing it on the client side upon receiving a Rep notify that the inventory changed
Ok, i see what you mean, Im still stuck on how to update the client the dropped the item though? Like how can I get their hud to update it, currently, the drop item function is being called on the server and the logic to update the players hud is also in here, Therefore it updates the servers hud instead of the client that drops the item.
WB HUD is established on the creation of the inventory component and is specific to the player characters hud per client, and since huds and widgets cannot be replicated I’m not sure how I can communicate that.
Mark your HolsteredItem variables as RepNotify, which will create notify functions that will run when the value is changed
So then in these functions you can update your hud accordingly
What you could do is only broadcast an event, that the HUD can bind to and update itself
Thank you, I think i will actualy try this, However I did just find a work around to my problem, I took the function off the server call and made all the other functions inside run on server except the logic to update the hud.