I have developed a game in unity it is a Carrom game (similar to snooker). I am trying to make it multiplayer using UNET HLAPI but I am stuck. I cant understand what should be the correct way to do this I am using a server authoritative model and used the striker as the player prefab but Whenever I strike the pieces move at the client side but not the server side. I tried sending a command to the server but than it does't collide with the pieces nor does it update on the client. So I wanted to know what should the the way to go? Do I keep the striker as a player prefab? and if not how does a player move it to take strike and what should i do at the pieces. Current all of them have a networkidentity and transform. I thought of assigning client authority on each turn but it does not remain server authoritative.
Asked
Active
Viewed 66 times
0
-
If I remember correctly the `Commands` work only if sent from an object which has local authority. So you should give your players local authority and then send the input infos to the server with a command. You do the physics computation on server. an alternative to commands are `NetworkMessage` – Massimo Frasson Jun 25 '18 at 13:05
-
I tried but if I apply physics to the game object on server it doesnt reflect on clients maybe because of local authority. Moreover the object doesnt collide with the pieces. They are pre added to the scene – Ali Raza Jun 25 '18 at 19:56
-
You're right. I think you should remove the authority to the current players and add them a `NetworkTransform`. Then the clients send the input through a [NetworkMessage](https://docs.unity3d.com/ScriptReference/Networking.NetworkMessage.html) to the server. For the collision issue I don't have ideas right now. Try what I told you and let us know! – Massimo Frasson Jun 25 '18 at 20:06
-
Actually this needs to be a mobile game with the striker moved by touch. If the players don't have authority they can;t move it. Sending touch points and then detecting on server would be slow I think – Ali Raza Jun 26 '18 at 21:03
-
Keep the authority and replace the command you were sending with a NetworkMessages. With the current informations this is the only help I can give – Massimo Frasson Jun 27 '18 at 11:03