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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Resolved System Choose Skin

Discussion in 'Netcode for GameObjects' started by kauanvicto700, Nov 19, 2022.

  1. kauanvicto700

    kauanvicto700

    Joined:
    Feb 2, 2022
    Posts:
    2
    I'm trying to make a system to be able to choose the skin at the start, I just wanted to change the NetworkManager's PlayerPrefab but I wasn't successful so I decided to instantiate a different player Prefab for each player but it instantiates more only for the host, the client is on the start screen as if it had not connected, but his Prefab instantiates on the host.
     
  2. lavagoatGG

    lavagoatGG

    Joined:
    Apr 16, 2022
    Posts:
    96
    Did you network spawned the prefab when instantiating on host?
     
  3. kauanvicto700

    kauanvicto700

    Joined:
    Feb 2, 2022
    Posts:
    2
    I managed to solve it I just needed to add the Prefabs in NetworkPrefabs in NetworkManager
     
  4. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    105
    Hi @kauanvicto700 , I wouldn't recommend this approach, as it forces you to duplicate all player's script on different prefabs. Instead, I'd use a ServerRpc to make the client pick the skin, and a ClientRpc to notify the picked skin to all clients. You can use an ID to say what skin was picked, and load the skin prefab at runtime as a child of the player
     
  5. TestifyNow

    TestifyNow

    Joined:
    Feb 9, 2016
    Posts:
    24
    This does not support newly connected clients. NetworkVariable is a much better choice, as it gets synchronized when a player connects. BOOM headshot.
     
  6. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    105
    Correct! I was assuming that you make people choose only when everybody is in the lobby. But yes, if that's not the case, NetworkVariable is a better choice.