Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Third Party Mirror - Save original player who dropped an item and verify orignal player later

Discussion in 'Multiplayer' started by Olffff, Nov 10, 2022.

  1. Olffff

    Olffff

    Joined:
    Jan 19, 2021
    Posts:
    1
    Hi,

    This is gonna be hard to explain. I am trying to build a game where 2 players can drop their limbs and then later pick them up again. When the limbs are either dropped/thrown, my script instantiates new objects into the scene which are server owned.
    There is a special case where if a limb is thrown out of the world it should return to the orginal player who dropped it. My question is how do i best save and verify the identity of this player when the limb is dropped and later pickedup when it falls out of the world. In short i need away to save the orginal owner of an object and later return this object to the same owner.

    I was thinking of saving the network identity to the script when the limb is instiated and then using that to verify.
    If anyone got any suggestions please reply!

    On Instantiate(on the playerScript):

    Code (CSharp):
    1. newSceneObject = Instantiate(wrapperSceneObject, position, rotation);
    2. SceneObjectScript = newSceneObject.GetComponent<SceneObjectItemManager>();
    3. SceneObjectScript.orignalNetworkIdentity = getComponenet<NetworkIdentity>(); //set the identity here
    4.  
    On fall out of world (inside the cript for the limb/object)

    Code (CSharp):
    1. public void HandleFallOutOfWorld()  {
    2.        if(orignalNetworkIdentity == localplayer.getComponenet<NetworkIdentity>()) //verify the identity here
    3.         {
    4.             itemManager.CmdPickUpLimb(gameObject);
    5.             itemManager.ReturnControllToPlayer();
    6.         }
    7.     }