So I’ve been scratching my head over this all day today and can’t seem to get anywhere. Essentially, I just want to print the Health and ammo for each player on their HUD. The server displays these values correctly, but the client does not.
To begin, both the ammo and health values in the Character C++ file are marked Transient and Replicated.
For dealing damage, I’m overriding the Actor::TakeDamage function in my character class, and here’s where a lot of my doubts start to creep in. In the function declaration, I haven’t marked it as replicated or on server or anything. If I try to do that, I get a compilation error that functions with a return type can’t be replicated. Inside the function I do a HasAuthority() check (another doubt - when am I really supposed to use this? Does it only make sense on functions executed on the server? or RPC/multicast functions? What’s the deal?).
If I start two instances in the editor,
ON THE SERVER : Both the server and the client deal damage and take damage. Updated Health and Ammo values are shown
ON THE CLIENT : Both the server and client always have the default health and ammo values. Updated Health and Ammo values do not reflect.
Any suggestions or discussion would be greatly appreciated. Thanks!