Search Unity

Unity Connection Handling

Discussion in 'Multiplayer' started by PranavSathy, Apr 19, 2014.

  1. PranavSathy

    PranavSathy

    Joined:
    Apr 2, 2014
    Posts:
    6
    Hey there Unity Community,

    This is my first post here, and my friends and I are doing a developmental server-client multiplayer game, nothing fancy just playing around with some fun features etc. So basically, I have written the server in C++ and of course the clients are all in C# (as the client uses Unity), and we can get pods running around to represent each one of us.

    Currently, we have a thread running to simply receive Data and parse it and store it into an PacketData class variable , where PacketData is just a class which conveniently allows us to retrieve specific chunks of info from the Packet. Then, in the Update() function, we parse the PacketData and spawn, delete and update clients as needed. The issue is, clearly this is time intensive and when there are 3 or more clients connected... it causes lag in the game. Is there any sane way to fix this problem, because I just cannot get it to work.

    I tried running the entire "parse data" block on a Loom thread, (from the Unity Gem/Threads page), and then just QueuedOnMainThread the things I needed on the main. However that just fails to realize the local variables in my class since the actual "Thread" is run on another class. What must I do do be able to handle these packets without causing lag? Thank you!
     
  2. PranavSathy

    PranavSathy

    Joined:
    Apr 2, 2014
    Posts:
    6
    Bump -

    I went towards an approach where a networkController prefab controls the server connection, and forces the localPlayer to update his or her position, as well as creates and updates remote players via spawning GameObjects.

    Would this generally be considered a better approach?

    Apparently passwords have to be over 8 characters long, that message doesn't show on Chrome , I used IE and it worked
     
    Last edited: Apr 22, 2014