Hello everyone!
I am not new to programming but to UE4 and currently have some issues understanding how the interactions between clients and the server proceed.
For my current project, as an example, I have multiple players. It is kind of an RTS game, so every player can own different types of building structures. First question: Should these buildings be pawns or actors? A player should own them but never really “possess” the building, eg look through them or move with them. In fact, they are static, but belong to a specific player can do stuff with it (other players also have to have the possibility to see it and attack it, but I think you know what I mean).
So, the main question(s) I have:
To realise building a base I thought about the following process:
1.) The player triggers an event, eg a click on the landscape, telling the game that he would like to build a base here
2.) A server request is send to the server, to validate all conditions for building a base for Player P at Position XYZ.
3.) If the conditions are valid, spawn a base-class-instance on the server and replicate it to all the other players.
4.) Later on, if a Player clicks on that base, send server request to validate if the base belongs to this player
5.) If yes, open building menue, if no, open attack menue
But here I have multiple questions.
If I send a server request, this request goes through the network to the server. Now he handles it and may spawn a base. But doesnt make that him being the owner of that base?
And when it replicates this base to all the other players, does that mean, that he triggers all other players to also spawn a base at this position?
Also, this Get Player Controller function confuses me. What does it mean? Do the player controller 0 to X represent all X-1 players on the server? If yes, how can I, the local player, determine which player I am? I know that I have a unique ID in the player State, but to obtain the player state I have just to extract it from the get player controller output…
When I spawn a class on server, I also have to give him an input, which player controller it should spawn on. But how can I determine inside a server function who send this request? I has to be possible to just create that thingy on the server with player identifier integer and duplicate that thing to every other player, 1:1…
Soo many ambiguities… I would virtually hug you to death if you could make things clearer for me a little bit. I think, I just have a big misconception about server replication and the interaction between clients and servers…
Best greetings!