Hey everyone,
I’ll try my best to ask this question properly, but due to my extreme lack of understanding about C++ based networking in UE4, it might seem convoluted.
I’m creating a networked FPS for my final project in college with another student. We’re hitting a roadblock at the basic process of shooting an enemy, and decreasing their health, replicating that value throughout whoever needs to know about it.
The problem is, we (and even some other groups also using UE4 for their final project) can’t figure out exactly how we’re expected to go from a hit event on the players local computer, to properly propagating that information around. Even with the current documentation and examples, we’re at a loss.
Hopefully some benevolent individual can come along and explain, as though we’re idiots, what we’re do do (in C++) to get this type of behaviour, and maybe explain how and why that is as well.
Thanks so much ahead of time,
I’d take a look at the shooter game example as it does exactly what you need.
However in short the following steps are needed:
- client player performs shoot action
- server is notified of shoot action via a RPC,
- server validates the shoot action and performs it on the server,
- If server validates the action it replicates the results of the action to all clients.
- meanwhile the client can simulate hit effects and wait for the server to perform the action to do the rule based gameplay stuff such as damage and health.
The server should be the entry that applies damage and notifies all clients of the damage via replication.
For more specific on what to look at in the shooter game example check out my answer in this post
Hey, thanks for the response.
I’m currently on a skype call with a few of my buddies, and we still can’t seem to wrap our heads around this concept. Especially since we’re testing Role == Role_Authority and both instances of the game are ROLE_Authority. How else can we check if it’s the server? We’re looking at the Shooter Example but none of it is really documented so we still can’t really make sense of it. We’ve been at this for weeks, and everyone just keeps sending us and everyone else to the shooter example.
Unfortunately, we need a bit more clarification since we can’t get it to work at all, let alone a little.
You can run a single client /server instance in editor to test basic replication. Try that locally to test your code. You should clearly be able to see the RPC calls moving between the client and server while debugging. I can’t think of anything that would ever cause two instances of a game to both have Role_Authority.