Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MCoburn

Pages: 1 2 [3] 4 5
31
TNet 3 Support / Re: TNet: Lag Emulation, Kicks and Bans
« on: December 31, 2014, 10:34:04 PM »
Alright, thanks for that.
Is there a way to wait until TNet has started the server before running commands to connect to it locally, etc?

What I see is that I do the TNServerInstance.Start(...) call and then connect to it. However, that call seems to return immediately, and doesn't wait until the server is up. Therefore my code that tries to connect to itself gets executed straight after the server starts booting, and gets a "No connection could be made due to the host rejecting the connection".

I see that TNServerInstance has isActive and isListening...


I was doing it wrong. Next question:

When you said to send them a disconnection packet, is it possible to use the packet with something like tno.Send(Packet.Disconnect, <insert player reference here>) ? Of course, if I try using "Send" it throws a error, but I see under TNManager.client there's also BeginSend and friends. The issue with that is the server needs to be the one forcing the disconnect, and that command only sends the message to the server unless I'm mistaken. Alternatively, I make a Kick() function that is an RFC, but I can see the odd smartass trying to be clever and avoid the kick by using a hacked version of the assemblies in the built game executable.

32
TNet 3 Support / TNet: Lag Emulation, Kicks and Bans
« on: December 30, 2014, 10:06:35 PM »
Here comes the list of questions... well, the start anyway...

1. Is there a preferred way to emulate lag on a network connection? I'm working on a shooter and I need to emulate lag on a local area network. Since on a LAN you have sub 50ms pings, lag compensation won't really helping much... well okay, maybe a little bit. What I'm trying to achieve is a emulated lag setup where a host is in Australia and you connect on a poor link from the other side of the world with 300 to 999 ms pings.

The reason I ask is I'm going to start doing lag compensation and I need a laggy setup so I can determine if clients are falling behind the server and if so, pop up a warning or show them the boot.

2. Is there a way to kick and ban clients (players)? Well, for kick I suppose we could refer to it as a forced disconnection since the server host will have the ability to say "Right, no more, you're getting the boot" and the client must obey. Bans could be implemented with the forced disconnections, I would just check the incoming IP against a local blacklist and if it's a match, bam, the client is gone.

I'll update the list as it goes on, but for now, those are my two priority ones.

33
TNet 3 Support / Re: RFC issues
« on: October 30, 2014, 08:06:41 PM »
I meant List<string>. This, on 2.0.0 was erroring about can't get a type, but since I upgraded to 2.0.1 I noticed in the change log that the "List<> type bug" was squashed.
I was trying to send a list of strings that would be parsed back into their respective script places (ie. int.TryParse)

I guess you're right about the server time. Would be better than getting each client's round clocks out of sync. How often is the server time updated - once per packet? I'm guessing if the player is > 1 seconds behind the server, then you'd see the "jump" where the clock used to say 9:45 and then it jumps to 9:40 because it's missing server time updates.

EDIT: Implemented the suggested idea, I had to get my head around the milliseconds to seconds business to display it right. No matter when the client joins, it gets the right time.

34
TNet 3 Support / Re: RFC issues
« on: October 29, 2014, 11:35:39 PM »
Don't send time. Use TNManager.serverTime.

Sorry, I think you misinterpreted what I wrote. The time value that gets sent across the network is what the server's round time is. For example, it might be 570 seconds remaining on the server which means that the client gets the 570 as an int in the List[] that I try to sync to the client. The client then fetches that value and converts that into the appropriate way to display the time remaining.

If I convert the List[] to a string using delimiters, and then do (p is the reference to the newly connected player):

tno.Send("SetGameOptions", p, theStringWithGameSettings);

then it will throw the error about serializing and whatnot on that string. So I'm either doing something wrong or TNet's serialization is not working as intended.

EDIT 2: Noticed some other odd things happening with the code, so it may not have been TNet's issue. I have updated TNet to the latest version though (2.0.1) so maybe a bug was squashed there.

35
You could poll the amount of clients inside a channel. That way, the server client has to be in there. If channel user count = 0, then throw a "Waiting for server... X seconds remaining" box that clicks down, which ultimately says "Host did not appear inside the specified timeframe". There's other ways of doing this, but that's a quick and dirty way.

36
TNet 3 Support / Re: tnet server crashing
« on: October 27, 2014, 10:58:58 PM »
Ah.  That did stop it from crashing.

Any suggestions what I need to check next?  Before I had multiple IPs, everything worked fine and UPnP did its job.  Now, no Gateway IP and UPnP fails. 

I do notice -ip use for either address still only offers the second IP address for the External IP.

Would you have any more suggestions?



Sorry, I made a typo. When you do the IP business, remove the use part of the ip parameter. So you should just get like server.exe -ip 127.0.0.1 .
UPnP may/may not work depending if you're on Amazon stuffs. Not sure about the gateway part tho. UPnP is only for auto-portmapping and isn't really essential if you've manually opened ports on firewalls.

37
TNet 3 Support / Re: RFC issues
« on: October 27, 2014, 02:02:31 AM »
Sorry to hijack the thread, but what would be the best way to send multiple values over the network?

For example, the time value that Demthios showed is one of the things I need to sync to clients, but I've tried to use a List<string> or string[] so that I can send a batch of ints and bools (at the moment it's 3 ints and a boolean) and TNet throws these errors when trying to send either a List<string> or a string[] with values in them:

  1. Argument cannot be null.
  2. Parameter name: type
  3. UnityEngine.Debug:LogError(Object)
  4. TNet.Serialization:Create(Type) (at Assets/TNet/Client/TNSerializer.cs:268)
  5. TNet.Serialization:ReadObject(BinaryReader, Object, Int32, Type, Boolean) (at Assets/TNet/Client/TNSerializer.cs:1369)
  6. TNet.Serialization:ReadObject(BinaryReader) (at Assets/TNet/Client/TNSerializer.cs:1114)
  7. TNet.Serialization:ReadObject(BinaryReader, Object, Int32, Type, Boolean) (at Assets/TNet/Client/TNSerializer.cs:1396)
  8. TNet.Serialization:ReadObject(BinaryReader) (at Assets/TNet/Client/TNSerializer.cs:1114)
  9. BinaryExtensions:ReadArray(BinaryReader) (at Assets/TNet/Client/BinaryExtensions.cs:59)
  10. TNManager:OnForwardedPacket(BinaryReader) (at Assets/TNet/Client/TNManager.cs:1085)
  11. TNet.GameClient:ProcessPacket(Buffer, IPEndPoint) (at Assets/TNet/Client/TNGameClient.cs:790)
  12. TNet.GameClient:ProcessPackets() (at Assets/TNet/Client/TNGameClient.cs:727)
  13. TNManager:Update() (at Assets/TNet/Client/TNManager.cs:1097)
  14.  
  15. Unable to create an instance of
  16. UnityEngine.Debug:LogError(Object)
  17. TNet.Serialization:ReadObject(BinaryReader, Object, Int32, Type, Boolean) (at Assets/TNet/Client/TNSerializer.cs:1370)
  18. TNet.Serialization:ReadObject(BinaryReader) (at Assets/TNet/Client/TNSerializer.cs:1114)
  19. TNet.Serialization:ReadObject(BinaryReader, Object, Int32, Type, Boolean) (at Assets/TNet/Client/TNSerializer.cs:1396)
  20. TNet.Serialization:ReadObject(BinaryReader) (at Assets/TNet/Client/TNSerializer.cs:1114)
  21. BinaryExtensions:ReadArray(BinaryReader) (at Assets/TNet/Client/BinaryExtensions.cs:59)
  22. TNManager:OnForwardedPacket(BinaryReader) (at Assets/TNet/Client/TNManager.cs:1085)
  23. TNet.GameClient:ProcessPacket(Buffer, IPEndPoint) (at Assets/TNet/Client/TNGameClient.cs:790)
  24. TNet.GameClient:ProcessPackets() (at Assets/TNet/Client/TNGameClient.cs:727)
  25. TNManager:Update() (at Assets/TNet/Client/TNManager.cs:1097)
  26.  
  27. Null field specified when serializing TNet.TcpProtocol
  28. UnityEngine.Debug:LogError(Object)
  29. TNet.Serialization:ReadObject(BinaryReader, Object, Int32, Type, Boolean) (at Assets/TNet/Client/TNSerializer.cs:1388)
  30. TNet.Serialization:ReadObject(BinaryReader) (at Assets/TNet/Client/TNSerializer.cs:1114)
  31. BinaryExtensions:ReadArray(BinaryReader) (at Assets/TNet/Client/BinaryExtensions.cs:59)
  32. TNManager:OnForwardedPacket(BinaryReader) (at Assets/TNet/Client/TNManager.cs:1085)
  33. TNet.GameClient:ProcessPacket(Buffer, IPEndPoint) (at Assets/TNet/Client/TNGameClient.cs:790)
  34. TNet.GameClient:ProcessPackets() (at Assets/TNet/Client/TNGameClient.cs:727)
  35. TNManager:Update() (at Assets/TNet/Client/TNManager.cs:1097)
  36.  

Funny thing is that the time value actually gets sent to the other client... which shows it correctly in the HUD's round timer...  :-\

38
Get rid of this. Keep the number of syncs low. In Windward I sync rigidbody once every 3 seconds. What I also do is sync the actual input axes values more frequently than that: every 250 ms, or if they change by more than 5%. This results in smooth movement as each player does their own input-based movement logic that gets auto-corrected every 3 seconds. Since my renderer is separated from the rigidbody (using LagPosition/LagRotation), the correction is also fairly smooth. Yes, this means that the colliders are a bit ahead of the renderer, but it's not noticeable at all in the game.

So I should chop the amount of syncs by half or more (from 10 to 5 or 3)?

I don't understand 100% what you mean by seperate the renderer from the rigidbody. Do you mean when moving the rigidbody is offset by a certain amount in front of the player and then it is back into place when the player is stationary? What is this LagPosition/LagRotation that you speak of?  ???

39
TNet 3 Support / Re: tnet server crashing
« on: October 27, 2014, 12:40:25 AM »
Try:

  1. <path to exe> -ip:<use first IP of server>
  2.  

I had a issue with this on my Linux 3 IP server box. Tnet would start up but then crash with a exception.
Why are you using cygwin??

40
There's a lot of things I can do to improve character sync across the network so that it doesn't look choppy. There's also the option of moving colliders forward when you move, but I'm not sure if that is the ideal thing for a shooter.

What I'm doing is trying to use Lerp with a modded version of the stock TNet Sync Rigidbody prototyping script. I've omitted the complete script and only listed the changes:
  1. [RFC(1)]
  2. public float positionLerpFactor = 0.01f;
  3. public float rotationLerpFactor = 0.25f;
  4.  
  5. void OnSync (Vector3 pos, Vector3 rot, Vector3 vel, Vector3 ang) {
  6.         mTrans.position = Vector3.Lerp(mLastPos, pos, positionLerpFactor); // Lerp from the old pos to the new pos
  7.         mTrans.rotation = Quaternion.Lerp(Quaternion.Euler(mLastRot), Quaternion.Euler(rot), rotationLerpFactor); // Lerp the rotation to the new rotation
  8.         mRb.velocity = vel;
  9.         mRb.angularVelocity = ang;
  10.         UpdateInterval();
  11. }
  12.  

The result is a nicer, smooth movement of the player, but when it stops movement the player jerks a little bit forward then snaps back a bit into the correct position. I think this must be due to the Lerp "snapping". Rotation is still a little choppy but it does smooth it out to some extent since I'm updating the Rigidbody data 10 times a second over the network.

There's also this code block here, but I'm not sure if I'll touch this as this is the actual sync function:
  1. public void Sync () {
  2.                 if (TNManager.isInChannel) {
  3.                         UpdateInterval();
  4.                         mWasSleeping = false;
  5.                         mLastPos = mTrans.position;
  6.                         mLastRot = mTrans.rotation.eulerAngles;
  7.                         tno.Send(1, Target.OthersSaved, mLastPos, mLastRot, mRb.velocity, mRb.angularVelocity);
  8.                 }
  9. }
  10.  

So, anything I'm doing wrong or any suggestions?

41
TNet 3 Support / Re: tnet server crashing
« on: October 26, 2014, 07:32:24 PM »
That's not exactly the best report... what were you doing before it crashed? Did the binary show a console screen and then just die?

42
TNet 3 Support / Re: Destroy player objects on leave?
« on: October 23, 2014, 09:04:41 PM »
You don't need to do anything. When you create an object via TNManager.Create you get to specify whether it's persistent or not. By default it is, so when the player that created it leaves the object will be left behind. Pass a 'false' instead.

The issue is that I use TNManager.Instantiate to spawn my player prefab, etc. for example:

  1. GameObject myPlayer = GameObject.FindGameObjectWithTag("Player");
  2. TNManager.Instantiate(playerRagdoll, myPlayer.transform.position, myPlayer.transform.rotation);
  3.  

The issue with TNManager.Create it doesn't allow me to set the Vector3 for position and such. Unless I have to make it, then get that reference and go from there, but that seems a little of a runaround approach. Is there a function that I can pass a bool to so that it toggle persistence?

EDIT: Brain not working, noticed there's an overload I'm not using *facepalms*

43
TNet 3 Support / Re: RFCs looping, freezes TNet stack and Unity
« on: October 22, 2014, 12:12:02 AM »
Everything working as expected now - I'm using Unity GUI (from 4.6 Beta) to do the action log. Can confirm that the messages are broadcast and each client shows the messages on the screen. Thanks for the assistance.

44
TNet 3 Support / Destroy player objects on leave?
« on: October 21, 2014, 11:55:03 PM »
How does one destroy objects that belong to a player that just left the channel? For the moment, I have a script that is the host manager, and as it suggests, if you're hosting the game and the player leaves, it's supposed to clean up the mess left behind by the player that disconnected. Unity's Networking had a function like Network.DestroyPlayerObjects(), but I only can see in TNet that its Destroy only destroys single objects.

Or is it if I do Destroy(Player) that it will kill everything related to that player? I know I must be overlooking something but at least it's better to ask than waste time trying to run around in circles.

45
TNet 3 Support / Re: RFCs looping, freezes TNet stack and Unity
« on: October 21, 2014, 01:00:42 AM »
Yes, and yes. TNBehaviour is just a MonoBehaviour with a convenient set of functions/properties.

You must always have a TNObject in order to send messages. What I generally do is have a static TNObject already present in the scene from the start -- with ID of #1. I put all my generic scripts there -- game manager, team manager, game chat, etc. When I want to send a chat message for example, I do GameChat.Send, which does GameChat.instance.tno.Send(...) inside, calling an RFC that's a function inside the GameChat script.

Ah, I see... I might do the same and see how it goes.

Pages: 1 2 [3] 4 5