Note: Example code from the unity networking examples I suggest you to look into photon networking, it's an api from You send an RPC across the network and update the position of the ball in all clients.Īlthough using too much networkviews can be desastrous. And all you need to do about the ownership of the ball is:Įach player has its own ball, on an event, say the player kicks the ball. Save is as NetworkRigidbody and attach to your ball. Also, it still doesn't solve the problem of two players being really close to each other one will "win" and one will "lose" in this case no matter what. It's possible to adjust the time frame of reference for each object such that it runs on "received server time" when it's far away, and runs at "client local time" when it's close however, there are some patents issued around this area. ( ) When the optimistically forward-simulated data is wrong compared to what comes back from the server, the player will see snapping/corrections. If you're OK with players seeing "warping" effect in the case of interference, then use this same mechanism, but display player-local data "optimistically simulated forward" and display remote-received data "forward extrapolated" using a mechanism such as EPIC. For low-latency network connections, this is often totally acceptable for high-latency connections, it becomes very laggy. If you're OK with control latency, then the easiest way to do this is to use a server that resolves all the physics, and players send commands to this server, but display only the outcome of commands/simulations that come back from the server. In general, this is an impossible problem to solve such that everybody sees the right thing and nobody has any latency. I don’t even know if this solution would be possible or if another think should be do. The solution that I think would be the easiest (if possible implementing) will be changing the ownership of the NetworkView so that when it is the turn of team A his client controls (owns) all the balls, and in the turn of team B then its own all the balls. I don’t know if it is clear but that is the problem. My problem comes when ball from say team A hits a balls from team B, because the balls from team B have as owner his player and the writer of the position is that client then even when the ball from team A moves the ball from team B it will automatically reposition because the client that “writes” the position is the client from team B. The balls are rigidbodies and a synchronize only the position making a Lerp so it is more or less smooth (I don’t know if this is the usual way when working with RigidBodies in Unity). I’m currently synchronizing the balls by using a NetworkView per Ball, each one with the owner has the machine that run the team. I’m trying to develop a game similar to Air Soccer Fever ( ).
0 Comments
Leave a Reply. |