Search Unity

Seeking Network Guru Tutor - 20 minutes tops.

Discussion in 'Multiplayer' started by TheCasual, Apr 3, 2012.

  1. TheCasual

    TheCasual

    Joined:
    Sep 30, 2010
    Posts:
    1,286
    Hi everyone. I am in serious search of a Unity built in networking Guru. The information i seek is relatively simple (i assume) but largely undocumented in the reference articles. The little bit of information that is to be had , is to vague to be of much assistance.

    I need someone that knows unity networking very well , for no more than about 20-30 minutes tops, to give me a brief overview, rundown of how to implement level loading , changing , swapping, on the fly, for all players in a game. For eg : Diablo 2 , town portals, allow a player to leave the current level , and traverse to the closest town of their choice in another level. This does not affect any other player , and everyone goes about the game as normal.

    I have a fairly good grasp on networking in Unity, and have made several small Multiplayer apps, but not one of them has ever used a changing level scenario. This information is vital to me , and although i do not have any money to pay you for your time , i can offer your choice of many different character models , fully rigged , pending on your preferences , upwards of 100's of animations., all useable in any form of your choice commercially , except for resale as a stand alone character/package.

    Please Unity community, i am fairly knowledgable, and this should be a very quick dirty job :p I just cant find any information that seems to be of assistance to me in the refs o_O

    Thanks in advance.
     
  2. omgketchup

    omgketchup

    Joined:
    Mar 28, 2012
    Posts:
    41
    I know literally nothing about Unity, but maybe you want to make different "rooms" for each "zone"? For example, everyone logs into the town zone automatically, and then when they change zones, it's as if they entered a different game room that loads a specific scene (map, NPCs, whatever). Instead of calling the loadRoomInstance or whatnot from a GUIButton, just have a GameObject call it when the player interacts with it?

    Again, I'm brand new and have only skimmed some networking tutorials, so don't take that as gospel.
     
  3. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    First, what you'r asking for will take way more then half an hour to explain. And secondly I think you're going to be hard pressed to find anyone thats going to put down 1h+ of their time without pay.
     
  4. duhprey

    duhprey

    Joined:
    Nov 13, 2009
    Posts:
    166
    I've only done a version loading from a lobby scene to the game. Heres sample code, its based on the snippet from the unity docs. https://github.com/tosos/PHPMasterServer/blob/master/Sample_MainMenu.js

    The two important things are the level prefix and the communications pause. The level prefix is because the objects stored in a scene that have network views get a predefined view id. The number starts at one for each scene, so you don't want them to override the current scene so you set the network prefix.

    Pausing the comms means all status updates and rpcs to the objects will be queued up locally until the scene is loaded. That way the object actually exists when the status update or rpc comes through.

    One other thing, that script sets dontdestroyonload. This is important while waiting to reenable the comms because this object would get destroyed ... unless you do load level additively.

    Feel free to pm me.
     
  5. TheCasual

    TheCasual

    Joined:
    Sep 30, 2010
    Posts:
    1,286
    @FHolm, i completely disagree, im not a noob to programming, i just dont have *all the required unity networking skills*. That said , i know enough about networking , and i think i almost have it working just a few hours later, but not quite. That said , with the guidance of someone that knew it like that back of their hand , it would be trivial.

    Dhuprey , thanks , browsing over that now , and yes , its the levelPrefix that has been giving me grief im sure - although the pausing never occured to me either. Will get back to ya.
     
  6. TheCasual

    TheCasual

    Joined:
    Sep 30, 2010
    Posts:
    1,286
    Well so far no luck. I have no problems making all the connections , spawning players , etc, but when i try and load a player from lobby into a chosen level, they go to their loaded level, but on other client , that players character shows up in their lobby level. This is where my biggest issue is , is figuring out how to sort and prevent unwanted data in each level.

    Im sure its in the use of SetLevelPrefix and the messageQueue , as i am prolly passing wrong data, and am a little unclear exactly how they work, damn documentation. It needs a little better reference than *heres a simple level loader*...

    Possible im misunderstanding the use of that script , and general purpose. Perhaps its meant to only load *all players into a new same level , at the same time. I dont know , but its definately not working for having each player be able to step into a new level at activation points.



    Ugh!.
     
    Last edited: Apr 4, 2012
  7. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
  8. duhprey

    duhprey

    Joined:
    Nov 13, 2009
    Posts:
    166
    Actually I didn't realize all that you were doing. The messaging is still important but really only between the server and the player moving to the new location. What you really need is networkView.SetScope. I believe only the server needs to set it... when a player departs the level they need to be "unscoped" from all players in that level. That player then also needs to be unscoped from all instances in that last level. Also all the players who are not in the level need to be unscoped from the new level.

    Server management is even more complicated because youll want the server to LoadLevelAdditive. LoadLevel by itself is destructive to the current objects... which is bad for the players still in town. :) if your server is buff enough you could simply load all levels and on the client they load each level and once loaded the server sets their scope

    One other suggestion then. The level prefix should be a fixed number like town gets prefix 1, the dungeon gets prefix 2. You could just set it to the build order... unless you have levels being downloaded through assetpackages... either way you'll want consistent numbering that example I set just increments the prefix. You don't want that.
     
  9. duhprey

    duhprey

    Joined:
    Nov 13, 2009
    Posts:
    166
    Oh, actually. Setting the group number you can SetSending/ReceivingEnabled per group and per player. So that'd be an easy way to disable all the instances from a level the player is leaving. I think setscope may be easier for the player avatars themselves though. That way players can just be one massive group all to themselves.

    I might have to tinker with something like this sometime... sounds fun heheh :)
     
  10. TheCasual

    TheCasual

    Joined:
    Sep 30, 2010
    Posts:
    1,286
    Ah hah! , i knew i was missing something crucial. Ok , i need to play around and see what i can come up with here, thanks for the SetScope info. I knew i was definately missing something *key* to the overall picture, just couldnt figure out what was what .

    Again , thanks , and i will post back if anuything new.
     
    Last edited: Apr 4, 2012