In my FPS there are two replicated variables, currentAmmo and currentSpareAmmo and they get displayed on my HUD widget in the usual FPS way. Now I want the number displayed to match the actual number in the variable and seem to be running into a few problems with this.
On the server side, it works perfect. I currently have it start with a 5 round magazine and 120 spare rounds. So to start, it displays 5/120. Then after I shoot it says 4/120 and so on.
However on the client side, it seems stuck at 5/120. I have a print string in the weapon blueprint to display the values it should be and those are correct. I can’t seem to figure out what could be making it not display correctly. Are there any replication settings I might not know about? Thank you for any help!
shouldn’t be any (network relevancy / network cull distance would lead to replicate only relevant actors, but the default network cull distance is at something like 150 meters).
So I would make sure
(-) That the weapon actor is replicating
(-) That the weapon actor is only spawned on the server, never on the client
(-) That the CurrentWeapon variable of your BRCharacter is only set from the server, never from the client (or in other words, that server and client reference the same CurrentWeapon)
Otherwise I would go from a minimalistic example that works and try to find out (e. g. via prints) what goes wrong. For example just create one replicated variable inside your weapon, change it on the server at EventBeginPlay and print it on tick. If that works, then access that variable from your widget and print it there (e. g. on tick).
Sorry about the delayed reply on this, thank you for the help! I stepped through all of those points (and it helped fix some more bugs I didn’t even know about!). Nothing seemed to work, but what ended up fixing it was creating the HUD in the controller rather than the character