Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

DarkRift - Fast and Flexible Cross Platform Networking

Discussion in 'Assets and Asset Store' started by Jamster, Apr 20, 2015.

  1. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Does dark rift do client and server side network interpolation or just server side? (Or not at all)

    Also when you send data - can you effectively send any packet at all, or does it have to be vectors etc? I've noticed you shoving multiple types of data into your send packet - including vectors, I just wonder how you do interpolation if you allow for any packet to be sent?

    Thanks!
     
  2. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    No, DarkRift doesn't assume anything about the data so it doesn't do any interpolation on anything. What you send is exactly what you will receive :)

    Yes you can send anything so long as it's marked with the Serializable attribute, Vector2/3/4 are handled internally and converted to internal types so they can be sent though! I'd also recommend using DarkRiftWriters and Readers as you'll have much better control and performance, using the automatic serialisation is really just there for ease/laziness now!
     
  3. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Oh interesting DR doens't do interpolation - so what is the benefit of Darkrift over just a custom solution for networking? Just that its already done?

    thanks!
     
  4. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    Well for a start, as you say, it's already been built and you can start on your game immediately. More importantly though you don't need to worry about fixing any bugs, you have me to do that for you!

    It's taken me a year to build DarkRift 2, that's a year of work you'd be saving!
     
  5. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    I actually already wrote a full API and UDP client/server - the main thing i was looking for was interpolation because i was too lazy to implement that but I guess I'll do that instead now :D

    Thank you for all your help though it seems like its a great product for a great number of people.
     
  6. alpezaxxx

    alpezaxxx

    Joined:
    Dec 20, 2016
    Posts:
    17
    i control all players in game.. why ?????
     
  7. DarkFlameX1

    DarkFlameX1

    Joined:
    Mar 14, 2015
    Posts:
    13
    Checkout the Player example, you will need to disable the scripts(controller scripts) of the remote players when they are instantiated.
     
    Jamster likes this.
  8. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    287
    @Jamster -- alpha sign-up soon sounds great, please consider me as well. I'm still interested in DR-2, thanks! ;)

    // WildStyle
     
    DarkFlameX1 and Jamster like this.
  9. alpezaxxx

    alpezaxxx

    Joined:
    Dec 20, 2016
    Posts:
    17
    thank you, i follow yasil tut from yt and i have error

    Assets/Server/MySQLConnector/Connector.cs(10,20): error CS0101: The namespace `MySQLConnector' already contains a definition for `Connector'
     
  10. Dakkerst

    Dakkerst

    Joined:
    Oct 24, 2016
    Posts:
    9
    I'm getting this error with a custom DistributionType:

    upload_2017-3-11_15-18-41.png

    How do I specify what to do with it?
     
  11. Nexam

    Nexam

    Joined:
    May 14, 2016
    Posts:
    26
    Did you plugin correctly loaded ? What do you during "onDistribute" event ?
     
  12. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    Check that you don't have the same plugin in the Plugins folder twice, looks like something is getting loaded twice and causing clashes!

    Firstly, did you mean to send with a custom distribution type? If so, you need to have something in onDistribute to handle that type of message because otherwise DarkRift doesn't know what it's supposed to do with that message! If you have that then we have a problem!

    Jamie
     
  13. Dakkerst

    Dakkerst

    Joined:
    Oct 24, 2016
    Posts:
    9
    The plugin is loading correctly, but I was unaware of "onDistribute". Is there an example of supplying a custom function for this event? I effectively want the standard distribution types (0 - 4) to do what do now, and then add on something else.
     
  14. StarOfDoom

    StarOfDoom

    Joined:
    Feb 25, 2017
    Posts:
    11
    Hey,

    What would be the best way to have server-sided bots? (Such as just simple enemies moving, then sending their position to the client). I was thinking about using System.Threading.Timer, then iterate through all enemies and figure out who needs to move/shoot, and then tell the clients that info, but is there a more efficient way to do this? This seems almost as if it's a workaround.
     
  15. Vytek

    Vytek

    Joined:
    Apr 29, 2016
    Posts:
    50
    Hello everyone,
    I'll try to create a project example using VRTK (Virtual Reality Tool Kit: https://github.com/thestonefox/VRTK) and DarkRift.

    (I have got the pro license, but in the project I use for now free version)

    I write code for single object to grab with simulator system and move in all the client.

    but I recieve this error:
    http://imgur.com/a/7pb9c

    ObjectDisposedException: Cannot read from a closed BinaryReader.
    System.IO.BinaryReader.FillBuffer (Int32 numBytes) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/BinaryReader.cs:107)
    System.IO.BinaryReader.ReadUInt16 () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/BinaryReader.cs:513)
    NetworkObject.DeserialisePosRot (System.Object data) (at Assets/Scripts/NetworkObject.cs:94)
    NetworkObject.RecieveData (Byte tag, UInt16 subject, System.Object data) (at Assets/Scripts/NetworkObject.cs:51)
    DarkRift.DarkRiftAPI.FireOnData (Byte tag, UInt16 subject, System.Object data)
    DarkRift.DarkRiftConnection.ProcessMessage (NetworkMessage message)
    DarkRift.DarkRiftConnection.Receive ()
    DarkRift.DarkRiftAPI.Receive ()
    DarkRiftReceiver.Update () (at Assets/Libraries/DarkRift/DarkRift/Plugins/DarkRiftReceiver.cs:11)


    Download link to the project:
    https://1drv.ms/u/s!AiHUyxKoOWlHnyZcEHJJdQSav-Ay

    I did not understand, what is the problem?

    @Jamster

    This is the code in the object:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using DarkRift;
    5.  
    6. public class NetworkObject : MonoBehaviour {
    7.  
    8.     //The ID of the client that owns this player (so we can check if it's us updating)
    9.     public ushort objectID;
    10.     public bool DEBUG = true;
    11.  
    12.     Vector3 lastPosition;
    13.     Quaternion lastRotation;
    14.     Vector3 lastScale;
    15.  
    16.     void Start(){
    17.         //Tell the network to pass data to our RecieveData function so we can process it.
    18.         DarkRiftAPI.onData += RecieveData;
    19.     }
    20.  
    21.     void Update(){
    22.         //Only send data if we're connected and we own this player
    23.         if( DarkRiftAPI.isConnected ){
    24.             //We're going to use a tag of 1 for movement messages
    25.             //If we're conencted and have moved send our position with subject 0.
    26.             if((  Vector3.Distance(lastPosition, transform.position) > 0.05f ) || ( transform.rotation != lastRotation ))
    27.             {
    28.                 SerialisePosRot(transform.position, transform.rotation);
    29.             }
    30.             //Update stuff
    31.             lastPosition = transform.position;
    32.             lastRotation = transform.rotation;
    33.         }
    34.     }
    35.  
    36.     void RecieveData(byte tag, ushort subject, object data){
    37.         //Right then. When data is recieved it will be passed here,
    38.         //we then need to process it if it's got a tag of 1 or 2
    39.         //(the tags for position and rotation), check it's for us
    40.         //and update ourself.
    41.  
    42.         //The catch is we need to do this quite quickly because data
    43.         //is going to be comming in thick and fast and it'll create
    44.         //lag if we spend time here.
    45.  
    46.         //If it has a ObjectUpdate tag then...
    47.         if( tag == TagIndexVRTK.ObjectUpdate ){
    48.  
    49.             //...update our position and rotation
    50.             if( subject == TagIndexVRTK.ObjectUpdateSubjects.PosRot){
    51.                 DeserialisePosRot (data);
    52.             }
    53.         }
    54.     }
    55.    
    56.     void SerialisePosRot(Vector3 pos, Quaternion rot)
    57.     {
    58.         //Here is where we actually serialise things manually. To do this we need to add
    59.         //any data we want to send to a DarkRiftWriter. and then send this as we would normally.
    60.         //The advantage of custom serialisation is that you have a much smaller overhead than when
    61.         //the default BinaryFormatter is used, typically about 50 bytes.
    62.         using(DarkRiftWriter writer = new DarkRiftWriter())
    63.         {
    64.             //Next we write any data to the writer
    65.             writer.Write(objectID);
    66.             writer.Write(pos.x);
    67.             writer.Write(pos.y);
    68.             writer.Write(pos.z);
    69.             writer.Write(rot.w);
    70.             writer.Write(rot.x);
    71.             writer.Write(rot.y);
    72.             writer.Write(rot.z);
    73.  
    74.             DarkRiftAPI.SendMessageToOthers(TagIndexVRTK.ObjectUpdate, TagIndexVRTK.ObjectUpdateSubjects.PosRot, writer);
    75.             if (DEBUG) {
    76.                 Debug.Log ("Data sent: " + pos.ToString ("F4") + " " + rot.ToString ("F6"));
    77.             }
    78.         }
    79.     }
    80.  
    81.     void DeserialisePosRot(object data)
    82.     {
    83.         //Here we decode the stream, the data will arrive as a DarkRiftReader so we need to cast to it
    84.         //and then read the data off in EXACTLY the same order we wrote it.
    85.         if( data is DarkRiftReader )
    86.         {
    87.             //Cast in a using statement because we are using streams and therefore it
    88.             //is important that the memory is deallocated afterwards, you wont be able
    89.             //to use this more than once though.
    90.             using(DarkRiftReader reader = (DarkRiftReader)data)
    91.             {
    92.                 //Then read!
    93.                 //Read the ObjectID
    94.                 ushort id = reader.ReadUInt16();
    95.  
    96.                 if (DEBUG) {
    97.                     Debug.Log ("Id: "+id.ToString());
    98.                 }
    99.  
    100.                 //The upate is for this object
    101.                 if (id == objectID) {
    102.            
    103.                     try
    104.                     {
    105.                         transform.position = new Vector3 (
    106.                             reader.ReadSingle (),
    107.                             reader.ReadSingle (),
    108.                             reader.ReadSingle ()
    109.                         );
    110.  
    111.                         if (DEBUG) {
    112.                             Debug.Log ("Position Readed");
    113.                         }
    114.  
    115.  
    116.                         transform.rotation = new Quaternion (
    117.                             reader.ReadSingle (),
    118.                             reader.ReadSingle (),
    119.                             reader.ReadSingle (),
    120.                             reader.ReadSingle ()
    121.                         );
    122.                    
    123.                         if (DEBUG) {
    124.                             Debug.Log ("Data recieved:" + transform.position.ToString ("F4") + " " + transform.rotation.ToString ("F6"));
    125.                         }
    126.                     }
    127.                     catch (KeyNotFoundException)
    128.                     {
    129.                         //Probably not aware of them yet!
    130.                     }
    131.                 }
    132.             }
    133.         }
    134.         else
    135.         {
    136.             Debug.LogError("Should have recieved a DarkRiftReciever but didn't! (Got: " + data.GetType() + ")");
    137.             transform.position = transform.position;
    138.             transform.rotation = transform.rotation;
    139.         }
    140.     }
    141.  
    142. }
    143.  
    Thank you for your help!
     
    Last edited: Mar 16, 2017
  16. Nexam

    Nexam

    Joined:
    May 14, 2016
    Posts:
    26
    @Jamster
    Got a technical question. When i send bytes with Darkrift, do you fill a buffer and wait the buffer to have a decent size, let say 512 bytes as example and send it anyway if the buffer existing for too long, like 10ms ?

    Because during a loop, i can call SendReply several time. If you send every packet independently, it can slow down the server a lot, because we need to wait the acknowledgment of the client that say it received the packet before sending the next. If you fill a buffer, it will send the buffer, so many packet at a time.

    And others quick question:
    I use ConnectInBackground() on the client side to prevent the screen to freeze while is trying to reach the server. However there is no way to connection? See if the client is actually trying to connect in background? Cancel the connection?
    My problem is: If i do a normal Connect() i can catch any error (like server is not available) but the client is frozen, if i use ConnectInBackground(), the client is not frozen but i can't catch any error or even check what is going on or cancel the connection attempt.

    Did you the the Connection.Close() problem ?
     
  17. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    That shouldn't be hard, all you essentially need to do is check the distribution type and return false if its 0 - 4 (indicating you haven't handled distribution yourself) or of not distribute it how you would like and return true to suppress the built in distribution :)

    I would disagree that that's a workaround, I think that's a perfectly good way of doing it! You could potentially use individual timers for each enemy but that might just make more work for you!

    @Vytek That's usually caused by 2 bits of code handling the same tag, when it leaves the using block of the first handler it closes the reader and so when the second handler comes to read it it's already closed and can't be read!

    I'm afraid I don't have time to look through your code but have a look for 2 handlers handing the same tag :)

    @Nexam Since DarkRift 1 uses TCP it fills buffers before sending so it wont wait for acknowledgements for each packet before sending the next! You should be able to use Disconnect to cancel a connection call that's been made in the background but you're right ConnectInBackground probably shouldn't eat errors!

    Jamie
     
  18. StarOfDoom

    StarOfDoom

    Joined:
    Feb 25, 2017
    Posts:
    11
    My main worry is performance impact. I have no clue how much performance some of the stuff im doing is taking. Would making a new thread for every enemy (potentially 500+) impact performance very much?
     
  19. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    Making a new thread for each enemy would because they're operating system constructs and are pretty heavy (they have their own call stack, and you incur penalties for the context switching between them every 15ms). If you're using System.Threading.Timers, however, then it's actually done using a queue and the .NET thread pool so uses resources very efficiently. DarkRift is entirely based off the threadpool and is one of the reasons it has such good performance!

    Jamie
     
  20. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    Just had five minutes free time and looked again at the code, think I've fixed your ConnectionService.Close bug!
     
  21. Nexam

    Nexam

    Joined:
    May 14, 2016
    Posts:
    26
    You are my hero !
    I will check this as soon as i can :)
     
  22. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    It's not pushed to the store yet before you can't find it! :)
     
  23. StarOfDoom

    StarOfDoom

    Joined:
    Feb 25, 2017
    Posts:
    11
    Hey,

    Do you know the ideal (or max) size of a packet I should be sending before splitting it into two? I found out that, unfortunately, sending a bunch of packets (50+ a second it seems) just kills performance for the client, so knowing the ideal/max size of packets I should be sending would be nice. (Or if your server handles packet splitting itself if I hit the TCP size limit).
     
  24. McNalYoo

    McNalYoo

    Joined:
    Mar 13, 2017
    Posts:
    2
    Hi,
    I'm trying to Build a project for VS I get these errors as if it couldn't find the dll



    Do you happen to know where the error come from ?

    Thanks in advance,
     
  25. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    Since it's TCP any big packets will be split automatically so there's no need to worry there. Ideally you want to send the minimal amount of packets however so that you don't flood the client/server :) So bigger, fewer packets are better!
    Hmmm, not see that before! Try removing and reimporting DarkRift, if that doesn't help try it in a fresh project!

    Jamie
     
  26. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    643
    DarkRift website down?
     
  27. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    Yeah... I forgot about that...

    I need to get a better host :(
     
  28. Dakkerst

    Dakkerst

    Joined:
    Oct 24, 2016
    Posts:
    9
    You should consider hosting with GitHub Sites, if it's suitable. Free of charge :cool:
     
  29. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    Website should be back online now!
     
  30. alpezaxxx

    alpezaxxx

    Joined:
    Dec 20, 2016
    Posts:
    17
    how use camera for multiplayer ??
    i dont understand i have smooth foolow script and i put in Main camera.. but the camera not follow my player target

    edit: why i cant see other players animation ?? hhh [noob]
     
    Last edited: Mar 27, 2017
  31. 2Darkslayer

    2Darkslayer

    Joined:
    Dec 8, 2015
    Posts:
    1
    im having an issue with my plugin when data is received like here

    void OndataReceive(ConnectionService con,ref NetworkMessage msg) {
    msg.DecodeData();
    }

    when i use this in my client

    using(DarkRiftWriter writer = new DarkRiftWriter()) {
    writer.Write(0);
    DarkRiftAPI.connection.SendMessageToAll(0, 0, writer);
    }

    but when i use

    DarkRiftAPI.connection.SendMessageToAll(0, 0, 0);

    there is no Error ... what is happening :/
     
  32. Lisk

    Lisk

    Joined:
    Oct 23, 2013
    Posts:
    97
    When calling ConnectionService.SendNetworkMessage, there is a DistributionType parameter we can pass.

    What are the differences between the different DistributionTypes?

    - All
    - Custom
    - ID
    - Others
    - Reply
    - Server

    I notice different behavior in my application if I switch from DistributionType.Reply to DistributionType.Server for example.

    Edit: Another question: What might cause the server to disconnect a client, without the client realizing it is disconnected?

    I am experiencing an issue where I send a lot of data from server to clients, and the server calls onPlayerDisconnect, but the client never actually called Disconnect or exited.

    Does the server automatically disconnect a client if it is sent too many packets?

    Edit 2: Emailed you Jamie with a video + source code repro of the above issue.
     
    Last edited: Mar 28, 2017
  33. StarOfDoom

    StarOfDoom

    Joined:
    Feb 25, 2017
    Posts:
    11
    Is there any way to debug or profile without writing our own mock interface to simulate yours? That's kind of a big deal with video game servers as they can get large and need to be profiled and debugged, but since your server takes plugins in .dll, it doesn't seem there's a way to debug without print statements (which is extremely slow and makes debugging larger issues a big problem).
     
  34. Lisk

    Lisk

    Joined:
    Oct 23, 2013
    Posts:
    97
    These are good points. Here's what I did:

    1. Create a console application in the same solution as your plugin. In the console application main method, call DarkRiftServer.Bootstrap(...) to boot up DarkRift.

    2. Make sure that the working directory is set to the one containing your /Plugins/ folder. I just use Directory.SetCurrentDirectory().

    3. Set the console application as the startup project and just use the normal Visual Studio Profiler to profile the server.

    I might have missed a few intermediate steps, so feel free to reply if you are stuck. Wasn't sure how familiar you were with setting up/attaching the profiler.
     
  35. StarOfDoom

    StarOfDoom

    Joined:
    Feb 25, 2017
    Posts:
    11
    Thanks for the really quick reply! There's quite a few arguments that go into DarkRiftServer.Bootstrap(). Where can I find out what to put there? I don't even know what "Mode" is. (Looks like an enum by the coloring but not sure)
     
  36. Lisk

    Lisk

    Joined:
    Oct 23, 2013
    Posts:
    97
    Np! I just use something like:

    DarkRiftServer.Bootstrap(
    Mode.Standalone,
    4296,
    65536,
    false,
    (x) => Console.WriteLine("[Info] " + x),
    (x) => Console.WriteLine("[Warning] " + x),
    (x) => Console.WriteLine("[Error] " + x),
    (x) => Console.WriteLine("[Fatal] " + x),
    null,
    null
    );
     
  37. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    I'm afraid you're going to have to provide more information than that! What's your current setup? What's going wrong? What have you tried?

    Can you give more information? Is the data received correctly?

    The differences are how the server forwards the message after it's been passed to onData. So All will forward to all clients including the one that sent it, other is similar but without the one that sent it, ID is to a single specified client, Server is to the server only and Reply is for messages sent back from the server.

    No need for all that :) Just attach your normal debugger to DarkRiftServer.exe!
     
    Lisk likes this.
  38. Whackeddie

    Whackeddie

    Joined:
    Mar 30, 2017
    Posts:
    10
    Hey Jamster, love this plugin you've made. I'm just getting started using it to implement multiplayer into my Universal Windows Platform project for Xbox One. Before I use it, I want to make sure its viable for Windows Store/UWP projects and so I tried to export it so. I am able to export the playerdemo example project to .exe but when I try to export to the windows store and run from visual studio, I get some reference errors?

    Here's my output log:
     
  39. Lisk

    Lisk

    Joined:
    Oct 23, 2013
    Posts:
    97
    @Whackeddie: I don't have personal experience with publishing to Windows Store/UWP, but a quick search suggested that Windows Store/Phone doesn't support BinaryFormatter (which DarkRift uses)

    http://answers.unity3d.com/questions/705415/read-write-data-for-windows-storephone-c.html

    Maybe it might be worth searching along those lines?

    @Jamster:

    Thanks for the answer. I have another question: Do you foresee any performance/concerns with running several instances of DarkRift on the same server machine? (say, like 10 instances?) Because my game logic is very computationally heavy, I'm planning to only have about 100 concurrent users per server machine. DarkRift seems so lightweight and have such low overhead that it seems like I don't need a Rooms implementation, but can just run 10 instances side-by-side (and my matchmaking code will handle making sure they connect to the correct instance). What are your thoughts?

    P.S. Anyone new here, feel free to join the DarkRift Slack channel! Just realized it was only mentioned in the DarkRift 2 thread, but not here.
    https://darkriftunity.slack.com/shared_invite/MTUyMDE3ODg4NTEzLTE0ODkxNjIwOTUtYWY4ZTU2YjkwYg
     
    Jamster likes this.
  40. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    Ah... Sounds like Lisk has it! I've never tested it with UWP, but I'm fairly sure DarkRift 2 will work fine with it if you can wait! (If it doesn't I will make it!)

    Are you using embedded servers? It will be very dependent on your plugins and your specs really but you should be able to get a good number going, particularly if they're standalone.
     
    Lisk likes this.
  41. Lisk

    Lisk

    Joined:
    Oct 23, 2013
    Posts:
    97
    I'm using a standalone server. Cool, that's good to know!
     
  42. Whackeddie

    Whackeddie

    Joined:
    Mar 30, 2017
    Posts:
    10
    I'm going to look into what Lisk has posted and see if I can't figure it out on my own, and also I am planning on switching to DR2 when it releases, so please make sure it works for UWP export so us Xbox Live Creators Program users can release our networked projects with darkrift!

    I'll look into this now! Thank you!
     
  43. Whackeddie

    Whackeddie

    Joined:
    Mar 30, 2017
    Posts:
    10
    Okay, so after a few hours of research I have found that exporting with IL2CPP shared libraries instead of .NET shared libraries is the only method that will work, since DarkRift depends on too many .NET 3.5 Dependencies. My export is running on Xbox One, however it currently is not connecting to the server, not sure if I am missing permissions for UWP/Windows Export to use networking. Will look into this more tomorrow.
     
    Lisk and Jamster like this.
  44. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    Glad to hear you've found a solution! It would be good if you could participate in the alpha testing when it comes!
     
  45. Whackeddie

    Whackeddie

    Joined:
    Mar 30, 2017
    Posts:
    10
    I would absolutely love to :) really like the plugin system and I love coding in C#, so I can only see myself using DarkRift for my game. If DR2 works flawlessly for UWP on Xbox One, I will be absolutely using it alread
     
    Jamster likes this.
  46. StarOfDoom

    StarOfDoom

    Joined:
    Feb 25, 2017
    Posts:
    11
    @Jamster is there a way to get the time since the client has sent a packet? (So basically 1/2 of Ping, just from client to server)

    EDIT: Just going to use DateTime.UtcNow, that seems like it'll be the best option.
     
    Last edited: Mar 31, 2017
  47. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    Not built in. It would have to be based of the time the client sent which would be unsecure :/
     
  48. StarOfDoom

    StarOfDoom

    Joined:
    Feb 25, 2017
    Posts:
    11
    Hey @Jamster, sorry for all the posts.

    I just recently download a program to start simulating a little latency to see how my game performs, and it's really, really crappy. Right now it looks like if I have 1000 ping, it's receiving one packet at a time, at a rate of one per second, instead of just receiving the packets a second late, but still at the same rate I send them. Which is obviously very unplayable.

    It seems like it's constantly trying to catch up to something, but i'm not sure what, and i'm about 90% sure it's not me. If I set my ping to ~5, it gets unplayable, things happen crazy slow, and then if I set it back to 0, it just instantly catches up.

    EDIT: Here's a quick video showing what I mean. It just gets SUPER backlogged, instead of just receiving them delayed. Is this something that i'm doing wrong, or something that DarkRift is doing?

     
    Last edited: Apr 1, 2017
  49. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,048
    I suspect it's mainly down to DarkRift using TCP and TCP's sliding windows for congestion control, though I can't be sure. It seems very odd that there's such a large delay at the start. What does it look like if you enable logging of data on the server does the server?
     
  50. StarOfDoom

    StarOfDoom

    Joined:
    Feb 25, 2017
    Posts:
    11
    I just did, it looks like the data gets to the server within the time put in (5ms in this example), but the cilent doesn't recieve the data and process it until much, much later. (It actually does look as if even with the ping delay off, the same thing is happening as far as a delay between the two clients. This doesn't happen if I have data logging off, just if it's on. I believe this is because of server lag, prints are expensive and i'm recording my screen, which is also expensive.).

     
    Last edited: Apr 2, 2017
unityunity