Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  3. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

How to make my Login System networkable?

Discussion in 'Scripting' started by itzcrazyzockt, Dec 7, 2018 at 11:58 PM.

  1. itzcrazyzockt

    itzcrazyzockt

    Joined:
    Friday
    Posts:
    2
    im new to networking in Unity and at the moment im trying to forge my Login System together with a multiplayer test. I logged into two different Accounts (tesuser & Funex - mirrored in the picture below, just ignore it) and let them join on one server. But as you can see in the picture below they have the same name on each build. (Blue marks the Local player on every build). In the code you can see the script that sets the username and kills Text for every player. (DBManager.username and DBManager.kills are the variables that are connected to my online database). Do i have to add something in order to make it work?

    Cheers Screenshot_2.png Screenshot_3.png
     
  2. qaisAhm

    qaisAhm

    Joined:
    Nov 21, 2015
    Posts:
    6
    Look into NetworkBehaviours, they have the same features as MonoBehaviours but add lots of networking features. Your code doesnt check if its the local client so they run on all your clients thats why you end up with the same name on both. If you want the name change to only happen on the local client you need to check for IfIsLocalPlayer before setting the name or moving it.

    You can find more info on IfIsLocalPlayer here >> https://docs.unity3d.com/ScriptReference/Networking.NetworkBehaviour-isLocalPlayer.html
     
  3. itzcrazyzockt

    itzcrazyzockt

    Joined:
    Friday
    Posts:
    2
    I already used if(islocalplayer) in another script so ill test it out as soon as im home, thanks for your help :)