Download

Clarification about replicating

Hi all,
I need a bit of a clarification about what belongs on the server and what on the client for my network game.

The game features a basic pick-up system where characters run over coins and they are automatically picked up and added to the character’s inventory.

My understanding is that the final decision as to whether the character is successful in picking the coin up should be determined by the server, but what work should get done on the client? Do I do the overlap collision detection on the client and then notify the server that the client has intersected with a coin and then the server checks that the intersection is valid? Or do I do all the collision detection on the server?

Cheers

The collision event will be called on the server and on the client.

For logic that should just occur on the server you guard it with:



if (Role == ROLE_Authority)
	{
		//server logic
	}		


But before any of this, I recommend going through Billy’s networking video tutorials : https://www.youtube.com/playlist?list=PLZlv_N0_O1gaCL2XjKluO7N2Pmmw9pvhE

They’re in blueprints but the concepts translate into C++.

He gives you some good rules to follow.

In your case, perhaps the client can play a sound or special effect that only the client is supposed to hear\see.

Ok, thanks for that. I was making things a lot more complicated - I was looking at UFUNCTION (Server, WithValidation, Reliable).

Thanks for the link to those blueprint tutorials - I’ll check it out. I’m actually having trouble tracking down good resources for building C++ projects. The API and programming guide is good in some parts, but a bit vague in others. Do you have any suggestions?

Cheers

Man, I’m such a muppet. I just noticed there is a sticky at the top of the forum called Wiki Code Tutorials. I know what I’ll be doing for the rest of the day!

Hang in there, it’s not easy to get started. One thing extra I recommend is have several other copies of visual studio open for Unreal Tournament, UE4 Engine and the Shooter game. I’m always referring to them for ideas on how to implement something. Or you can use the Github search.