I am really sorry that I ask so many questions recently, but I hope that I can give back the help when I am more experienced with UE4.
I still have some understanding issues of how the GameFlow happens.
When I, the client, tell the server to create an object and in the _Implementation function say, that this is my (client) object. Does the server act like a client game, beside that he has no own playerController? I mean, does the server just sit there and handle RPC calls or does he also simulate a game, like call tick() functions for every object on the server?
I came across this question as I wanted to implement the following function:
Every player has a City, created over the server, but the client is set as the owner via SetOwner in the _Implementation function of the Server RPC Call. Now, every city has a population which consumes food-ressources. Because a client could cheat and just bypass a RPC Server call to proceed this substraction, the server has to call the RPC call, on his own machine and on the owning client.
But how do I determine when and where to call this function? Can I write a UFUNCTION(client) function, that is called inside the tick() function of every City? I mean, I know, I can, but does the server really execute this tick() function (leading to my above question: Does the server simulate a game, synchronous to the clients)? Or how would I realize time based / triggerd events?
As far as I know, the server will execute your function even if it’s call in the Tick(). It does simulate a game, as synchronous as possible with clients
If you did’nt already check this, I recommend you to watch this course by Epic :
It’s really helpfull fot beginning a Server / Client game.
Client / Server communication is quite difficult when you start, but after a few experimentations, it is not that hard
The thing that you have to keep in my mind, is that all your game logic should be in the server part ! The client is here to make the communication between you’re program and the user.
Ah, and is there a RPC call that runs on the owning client and the server, called on the server? multicast runs on every client, doesnt it?
Because the Ressources should only be present on the owning client and the server.
Or how would I implement functions that happen on the server? Or do I just normally substract a certain amount in the tick() function? would this lead to substraction on both, client and server? my idea was then just to verify the ressources when they are needed, eg “trust the client as long as the ressources aren’t gameplay importend, eg when he tries to build something”