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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Access Objects on Other Networks

Discussion in 'Multiplayer' started by Wilelle, Nov 17, 2015.

  1. Wilelle

    Wilelle

    Joined:
    Jun 16, 2015
    Posts:
    93
    I've been trying to add the option to let the players of my two-player online game change skins, but the change is only visible to the player who did the change. So my solution to this is to make the other player call a function to change a player's skin when they do. But I can't seem to make that work, since I can't figure out how to access other players in a player's script. It's as if they don't exist in the scene. I can't find the other player by searching for its tag, its name, or anything.

    I should add that I'm a huge beginner at multiplayer stuff, so I apologize if this is a stupid question.
     
  2. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    I am not familiar with unet but what you can do is inside of a class on the object that spawns you can have the player "register" itself to a static list, or a manager, or something like that. Another way is that if there is a player joined event of some-kind you can grab the reference to the object from there.
     
  3. Wilelle

    Wilelle

    Joined:
    Jun 16, 2015
    Posts:
    93
    I have no idea why I never thought of using static variables... Over a week I've been messing around with all kinds of potential solutions, yet that one never occurred to me... Anyway, it works now! Thanks!