Search Unity

Sending input packages to authoritative server

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

  1. Diablo1399

    Diablo1399

    Joined:
    Jan 25, 2010
    Posts:
    5
    Hi Guys,

    I'm working on a 3D project with an authoritative server, and I'd like to know if it's possible to package together a client's input and send it to the server.

    For example, I want to call Input.GetAxis("Horizontal") on the server, and have it return the state of the client.

    Thanks
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you can't call that, but you can use RPCs to send the input and interpret it on the server.

    check the authorative server example within the network example (available in the resource area on the website)
     
  3. Diablo1399

    Diablo1399

    Joined:
    Jan 25, 2010
    Posts:
    5
    Thanks, I've looked at the tutorial, but is there a better way of packaging input rather than sending a whole bunch of variables?
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    There are two ways basically:

    1. Using an RPC. thats simple also from the programming way
    2. Network view and OnSerialize.... and then writting it to bitstream there.

    in the end both have the same effect -> data send in a bitstream / datapacket, and as you send input, in both cases it needs to be reliable.
     
  5. Diablo1399

    Diablo1399

    Joined:
    Jan 25, 2010
    Posts:
    5
    The RPC solution is elegant enough. Thanks for the help :)