Hey guys. So here is my situation.
I am making a multiplayer cardgame. On the beginning of the game 4 cards get layed on the field. The cards face down at the beginning (the prefab looks this way). Then I want to flip them. To do this I call a method on the card that rotates it half way, then changes the sprite to show the face of the card and then rotates the rest of the way.
This worked great on singleplayer but now it doesnt. The cards spriterenderer doesnt get synced to the clients. Only on the server the cards actually flip. The cards and the object that spawns them, aswell as the object that flips the cards exist on the server. I can see the cards rotate and move on the clients correctly, since they have a networktransform.
I have tried [SyncVar] on the renderer… nothing
I have tried [ClientRpc] and change the renderer in such a call but again… nothing. In this case the cards sometimes even dissapeared.
I should also mention that the flip method is a coroutine. Dont know if that is important.
If anybody could help me, that would be nice
You are taking the wrong approach.
You should solve this using Analogues.
An analogue is like “Linking by sight”.
Instead of trying to send complex data, simplify it and sync the simple data.
Essentially you only need to send a float for a rotation, for example and let the client handle the SpriteRenderer by using that rotation value.
In order to get the most from the UNet system, you must read the Manual from start to finish as it deals with important concepts throughout. It is impossible to work it out from the scripting reference.
You dont want the server to literally control each how each client works directly. That is like playing a game from someone elses machine. You dont want the whole game sent across the internet.
You want the server to give small ques. The client picks up on these and then performs the operations itself based on that.
Put it this way… Each client already has ALL the information it needs to process the game. Its identical on server and client (under default UNet setup). So theres no need to be sending so much information. Its already got it. Just use little controls (of your own design if need be) of simple types to make this happen. Analogues.
Minimising bandwidth is essential in multiplayer gaming.
So you are not trying to control each sprite renderer directly from the server. The server simply gives a number based on where it wants the thing to be and the client reads that number and responds to it.
Am I making sense here?