Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

Networking - Best way to Sync Rigidbodies?

$
0
0
Hello, I'm working on a type of pool/billiard game over a local network using Unity's builtin networking for iOS. I'm trying to figure out the best way to sync position of the balls. Basically, I want it so when it's **Player One**'s turn, that device only applies the actual velocity to the balls when hit, and then syncs the outcome of the position to the client / Player Two. And the same for when its **Player Two**'s turn. So who's ever turn it is, will essentially control the balls physics, and sync it to the client. What I've done so far is this, which is attached to all the balls (FYI, the initial force applied to the balls are also called locally, and synced in the same manor): function Update(){ if(GC.NETWORK.myTurn){ networkView.RPC("SyncVelocity", RPCMode.Others, rigidbody.velocity.x, rigidbody.velocity.y, rigidbody.velocity.z); } } @RPC function SyncVelocity(x : float, y : float, z : float){ rigidbody.velocity.x = x; rigidbody.velocity.y = y; rigidbody.velocity.z = z; } Note how I'm only sending that RPC to 'others' .... so the player that ISNT playing. Is this the correct way to do it? I'm worried that because I'm sending this every frame it might 'overload' the clients network listener ... if thats even a thing? I had also synced the local position and rigidbody velocity before, but when testing on my iPad2, and being the player who ISNT playing, everything went laggy, suggesting that there was too much data being sent from the current players RPC? (Although I didnt get lag when on my iPhone5 as being the 'none player'. Maybe because its just generally better at processing it all). I don't know, just need a point in the right direction really?! Thanks.

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>