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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

[UNET] Synchronize objects between players

Discussion in 'UNet' started by tigres810, Sep 9, 2017.

  1. tigres810

    tigres810

    Joined:
    Jan 29, 2015
    Posts:
    8
    For example I want to make, when a door of a car opens the two players see it fall at the same time and sync, how do I do that? The first player sees it well fall but the second sees it stuck and can not go down for that.
    The car is a swat truck, the door is the behind one and the door rotates down.
    Anyone who can help me, please?
     
  2. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,732
    You probably want to make your door opening function an RPC, so that it is executed on all clients
     
    tigres810 likes this.
  3. tigres810

    tigres810

    Joined:
    Jan 29, 2015
    Posts:
    8
    Yes! How I do that?
     
  4. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,732
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    How I would do it is the player that presses the button to open the door calls a command on their own player object. The command runs on the server, which calls some method on the vehicle gameobject that you use on the server to trigger the door to open. That method then calls a client RPC on itself that runs the door opening animation on all clients.
     
    Munchy2007 likes this.