Help understand RPCs (client to server calls)
I'm trying to have my client's weapon call a server function on overlap, but the server function is never called (in-spite of being the owning client).
According to documentation (https://www.unrealengine.com/blog/crash-course-in-blueprints-replication):
Shouldn't the following work?
Thanks in advance
asked Jul 05 '14 at 03:38 AM in Using UE4
First of, you forget to check if actor actually has authority inside your server RPC :)
And yeah, it should work like that, not sure what's the case..
I've got it up set like that(in example of weapon firing): Weapon::Fire() Weapon::ServerFire()
Weapon::Fire() checks for role, and if it's not ROLE_Authority, then it calls ServerFire, which is reliable server function. If it's authority - it processes firing.
Hope this helps you some way.
Forgot to mention that ServerFire simply calls Fire.
The Client calls RPC, but it runs on server. So anything later than red node TestServer will be executed ONLY on Server. In Epic's tutorials all firing, damage and other changes executed on server. This functions change replicated variables. And clients "feel" the result. So, if you want fire weapon, just call it from any client with RPC. On Server run bullit movement and hit detection. But health, bullit and other parameters are "Replicated". So, changes on Server will be seen on clients.
Server - gameplay calculations, clients - input, HUD, graphics and calling. You can make calculations on clients too, but first need training like I wrote, to make it feel!
answered Jul 07 '14 at 02:39 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here