Search Unity

Help with ball game

Discussion in 'Multiplayer' started by Zwakstroom, Feb 1, 2010.

  1. Zwakstroom

    Zwakstroom

    Joined:
    Jan 19, 2009
    Posts:
    27
    Hi,

    I have a simple networked game with 2 movable players and a ball.

    At the moment i have the ball movement server side and the movement of the players client side. The server is also a player. So when played on the server the ball is without delay, but on the client the ball is delayed thus affects gameplay, because the client movement is client side and state synced with server with a delay.

    How are these kind of things done with 2 players that can hit a ball with networking?
    I don't need code examples, i just want some theory(i don't mean a book) and/or unity focused advice. I've seen the M2H tutorial on networking, but doesn't help in my case.

    I've experimented with every move is done on the server, and the client is just an outlet. But with this construction the client movement seems lagged. I suppose i need some client prediction of some sort.

    Basically my question is, what's the best approach? If someone could point me in the right direction, then i know what to work with, instead of now trying out every thing and nothing works great.
     
  2. Bluestrike

    Bluestrike

    Joined:
    Sep 26, 2009
    Posts:
    256
    You are using a rigidbody ball?
    Did you tell the networkview to observe the rigidbody component of your ball?
     
  3. DrHotbunz

    DrHotbunz

    Joined:
    Feb 14, 2009
    Posts:
    315
    The best approach is for the players is to use roburs improved interpolation script from the wiki for the players and ball.

    Use a version of player local and have the server edit it for control of the ball that way every client has a non local version (but interpolated) version of your balls.

    Send robur a nice note saying thank you.
     
  4. Zwakstroom

    Zwakstroom

    Joined:
    Jan 19, 2009
    Posts:
    27
    Thanks guys for replying.

    I've been looking at the script from robur, but in my case i'm also using the server as a client.

    Do you think robur's can work in my case?

    @DrHotbunz: I don't really understand what you are saying. I understand using interpolated networked objects, but one player is server thus seeing everything realtime, and one is client. The client will always see things delayed. He sees the server player and the ball delayed. Then you can choose how to deal with the client player movement, that's my biggest problem.