Search Unity

How to UNIQUELY identify a Legacy Network.Instantiated GameObject?

Discussion in 'Multiplayer' started by jbarbeau, Jun 29, 2017.

  1. jbarbeau

    jbarbeau

    Joined:
    Dec 21, 2012
    Posts:
    46
    Hi All,

    I have a flight sim for the USFS, and it has 7 planes and 7 helos. Sometimes they want the SAME plane on MULTIPLE simulators. Each simulator has a cluster of up to 8 computers, so I use RPCs to communicate from the Master of Cluster to the slaves.

    If I have 2 of the same plane assigned, the slaves attach to the wrong version, because I use GameObject.Find("plane name"); on the slave to do what it needs to do with that gameobject, first it must attach a camera at the right orientation, according to it's view.

    I TRIED to create a UNIQUE IDENTIFIER when iNetwork.Instantiating a plane, but Plane.GetInstanceID() doesn't produce the same numbe on the Instantiator (Master) as the slave does. I also tried MANGLING the name of the object, addint a counter to the end. The Instantiated object comes up with the original name even if I change the name in the Master BEFORE instantiating it (I just thought of this... I should probably recheck this).

    DOES anyone KNOW how to make a UNIQUE Identifier of the Network.Instantiated Object so SLAVES can find the RIGHT object? I appreciate suggestions.

    Thanks
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Create a GUID or something alike on the Master , then send it over to the slaves. So that the slaves never produce anything themselves.
     
  3. jbarbeau

    jbarbeau

    Joined:
    Dec 21, 2012
    Posts:
    46
    I DID recheck, and the Slave has the ORIGINAL UNMANGLED name for the GameObject. Therefore it won't work this way. Any ideas on how to make a UNIQUE Identifier in Unity Legacy Networking? I think the new networking code has NetworkIdentity, I saw that in documentation. But I've gone WAY TOO FAR down the Legacy Network design to start over. Almost everything works now in my system.

    Thanks
     
  4. jbarbeau

    jbarbeau

    Joined:
    Dec 21, 2012
    Posts:
    46
    Thanks for your respons TwoTen, I did what you suggested, the problem is that the slaves PLANE has to have access to that GUID so the RPC can match what is RECEIVED in RPC to the GAMEOBJECT that has been Instantiated. I can find nothing on the GameObject to USE as a GUID. there is a member called m_InstanceID, and I think that is what .GetInstanceID returns, but THAT NUMBER is NOT the same as the value that GetInstanceID returns BEFORE i send it thru the RPC. I've checked this carefully.

    Unless I'm missing something, I tried, what you suggested.
     
  5. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    I am having a very difficult time understanding what you talking about. So please clearify.
    In my original post I assumed the following:
    By master you ment server
    By Slave you ment client
    By Plane you also ment client

    If you have airplanes. That are players (clients). Then make the server assign a UID for each plane (client).
    Then make the server send a message to all clients telling it it's ID's. That way everyone will have the same IDs.