Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Sending input over a network.

Discussion in 'Multiplayer' started by Tastie_Games, Oct 30, 2018.

  1. Tastie_Games

    Tastie_Games

    Joined:
    Dec 18, 2017
    Posts:
    3
    Hello World!

    I am developing a small local co-op game in my spare time for my girlfriend and I to play together(only problem being my girlfriend and I don't live in the same time zone.) I want to add a way to connect over the internet to play that way but my game has been built from the ground up to be played in local co-op. Meaning the characters on screen wait for a controller to connect and receive input based on the local input.

    Is it possible to make a game object with a script attached that is connected to a server that will read inputs for both players and send the inputs between both games over the internet?

    For programing help:
    - I am using the Rewired Asset for input management.
    - There is one script that is used to control both players on screen.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    This can be done with pretty much any available networking API. It is not going to be as simple as just sending inputs, unless you don't want the client to actually be able to see what is going on in the game. You're going to have to redesign almost everything in your game for syncing from the server to the client(s).
     
    azndesserts and Tastie_Games like this.
  3. Tastie_Games

    Tastie_Games

    Joined:
    Dec 18, 2017
    Posts:
    3
    I was afraid that might be the case. I cant make like a virtual controller that listens to the inputs entered by one client and repeats them in another clients game? Almost like how input works in Twitch Plays Pokemon, where you enter an input and then it enters that input in the game, except the inputs are entered automatically when you enter input from controller?
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I suppose so, but then you'll need to stream the game instead of the player being able to actually run a client for the game themselves.
     
  5. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    507
    This might be off-topic but since you said that you only made the game for you and your gf it might be a "workaround". Did you consider to keep the game local and use something like NVIDIA GameStream? It supports cases like these to play "local multiplayer" games online with a friend (There might be other/similar tools for this case, if you don't have a NVIDIA card)
     
    Tastie_Games likes this.
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,495
    If you just take a game designed for local-only play and then start passing input back and forth, there’s no guarantee that what’s happening on one player’s screen would be happening on the other player’s screen for virtually unlimited reasons. (Latency, inconsistent physics, frame rate differences, randomization of certain properties, time, etc.). You should build your game from the ground-up with the knowledge that it will be networked and design your systems around that. You need to be passing states rather than passing input.

    If you really want to pass input, use a Custom Controller to read it from whatever network API you use.
     
    Tastie_Games and LaneFox like this.
  7. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,383
    Or use a lockstep approach.
     
    guavaman likes this.
  8. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The nature of the original question tells me building the game around lockstep is too advanced a solution for his current experience level.
     
    LaneFox likes this.
  9. Tastie_Games

    Tastie_Games

    Joined:
    Dec 18, 2017
    Posts:
    3
    Oh wow! That's amazing! I'll look into this.