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

Storing Player Stats on Server using UNET

Discussion in 'UNet' started by edster3194, Jul 22, 2015.

  1. edster3194

    edster3194

    Joined:
    Jan 26, 2014
    Posts:
    4
    Hello Unity Forum!

    I am currently in the process of making a 2D, 100% UI driven game, that is single player as far as the gameplay is concerned. However, a big part of the game is seeing how you rank up against over players (basically leaderboards). I am at the point where I am ready to add the server, and I new that Unity had this new UNET thing that everyone seems to like.

    I watched a bunch of videos, and browsed through multiple example projects. I saw the use of a NetworkManager to sync the transform of player prefabs in a scene across all clients. I saw NetworkManagers controlling individual animators on each of the clients. I saw lots of really impressive other stuff done easily using the new network components...

    ... but I did not see anything equivalent to Unity's simple old RPCs, which I could just use to call a method with passed arguments on the server from the client, and vice versa.

    Am I overlooking something obvious? I tried to use the old netoworking system, but it didn't seem to work the same way (specifically, I could no longer use networkviews) and I later read that it had been depreciated to the point of being unusable.

    Any advice or help with just sending simple C# data types between a server and client (both ways) would be much appreciated. Thank you very much for your time!
     
  2. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Data is now sent with syncvars or with Command and ClientRpc. Command sends to the server (host is both server and client), and ClientRpc sends back to the clients. If you're just syncing a simple int or float, then syncvars should be enough. Take a look at this page of the manual for more details and examples. Or start with the first one if you didn't read the manual yet.
     
  3. edster3194

    edster3194

    Joined:
    Jan 26, 2014
    Posts:
    4
    Thank you very much for your very helpful response. I feel strongly after reading the script reference and manual on Commands and ClientRpc that they will give me most of the functionality I will need.

    I have continued my research on UNET and I have a very related, more general question. The networking that I need is very slim. I don't want a scene with a bunch synced PlayerPrefabs. I don't want anything more than the passing of data. I don't even really want my server to be related to Unity at all. Am I going about this the wrong way by using UNET?

    I am getting the sense that UNET is for multiplayer games that have players with transforms, and lobbies, matchmaking, etc. I see a lot of tutorials, examples, and documentation on how to do all this stuff, but meanwhile I can't figure out how to even get the number of clients currently connected to my server.

    Is there a simpler alternative that I am overlooking that would be more well suited for things like leaderboards and stat tracking? Thanks again for all your help.
     
  4. edster3194

    edster3194

    Joined:
    Jan 26, 2014
    Posts:
    4