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.

Topics - MCoburn

Pages: [1]
TNet 3 Support / What are the TNet equivilent of these UNet functions?
« on: September 12, 2017, 11:51:33 PM »
I'm starting to convert some UNet code over to TNet and I'm wondering what the TNet equivilent of the following functions are.
If you don't mind, this will be a on-going thread. I'm reading the sources and the examples slowly and starting to understand the events that TNet emits, but I'm a little baffled at the following:

UNet Function - Tasharen Networking Function
OnStartClient - ??? - maybe OnChannelJoin() ?
ClientRpc - ??? - RFC with a client check?
Command - ??? - maybe RCC?

Your pointers are much appreciated.


TNet 3 Support / Migrating from UNet to TNet: What's involved?
« on: November 12, 2016, 04:14:01 AM »

I'm using a third party asset from Opsive called the Third Person Controller and it has networking functionality such as an authoritative server that utilizes the default UNet stack. However, the problem is that UNet has a bug in it's Network Animator that stops characters from working correctly if I start a Network Server in LAN/Dedicated Mode as I want to be able to have a server running and not have to have a "player object" taking up room on the server slots. After research and hair pulling, I put the cards on the table and remembered I had a license of TNet I could use.

From what I see in the Third Person Controller's networking side of things, it uses a fair amount of UNet RPCs such as [Command] and [ClientRpc]. Most objects that need to be sent over the network have NetworkIdentities and NetworkTransform scripts attached to them, etc.

I know I'm possibly looking at a lot of code refactoring, but if UNet is going to give me pain I'd rather have TNet handling the network side of my game. Perhaps has someone already written a wrapper for this kit? Is it worth pursuing or should I just keep using UNet since the third party asset already has it working out of the box?

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.

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;
  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. }

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. }

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

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.

TNet 3 Support / [SOLVED] RFCs looping, freezes TNet stack and Unity
« on: October 20, 2014, 12:45:57 AM »
Alright, so here I am trying to make a Networked Kill Feed, so when someone frags the other player, it registers up in the frag list. This is the base script for that killfeed:
  1. public List<string> fragFeed = new List<string>();
  3.     void OnGUI()
  4.     {
  5.         // The frag feed.
  6.         GUILayout.BeginArea(new Rect(Screen.width - 320, Screen.height - (amtOfFragsShown * 24), 310, (amtOfFragsShown * 24)));
  7.         GUILayout.BeginVertical();
  9.         for (int i = 0; i > amtOfFragsShown; i++)
  10.         {
  11.             GUILayout.Box(fragFeed[i]);
  12.         }
  14.         GUILayout.EndVertical();
  15.         GUILayout.EndArea();
  16.     }
  18.     [RFC]
  19.     void AnnouncePlayerAction(string whatHappened)
  20.     {
  21.         Debug.Log("Got a player announcement...");
  22.         fragFeed.Add(whatHappened);
  23.     }

In the appropriate scripts, I have this. This is taken from the player vitals script, which is basically the "heart" of the player - if they die, it does all the required things on death (respawn, ragdoll, etc). This function is the one that gets triggered when you take the easy way out or you fall into the void and the level OOB triggers hit the character.

  1. // ......
  2.    private void KillSelf()
  3.     {
  4.         AnnouncePlayerAction(TNManager.playerName + " ended it all");
  5.         currHealth = 0;
  6.     }
  8.     [RFC]
  9.     void AnnouncePlayerAction(string whatHappened)
  10.     {
  11.         Debug.Log("Got a player announcement...");
  12.         to.Send("AnnouncePlayerAction", Target.All, whatHappened);
  13.         // fragFeed.Add(whatHappened);
  14.     }

However, the issue here is that it loops itself and basically freezes Unity or the Unity Player, requiring a Task Manager to kill the process. Basically, I want to have one script fire the RFC to "announce" the event, and then the other script, which is the Network Feed script, to pick up the message, add it to the list, and then go from there.

Could you assist?

TNet 3 Support / [SOLVED] Connecting to lobby server to get server list?
« on: September 23, 2014, 11:26:47 PM »
I'm trying to poll the TNet Lobby server for the list of servers, so my players can click one to join.

On my gameobject that controls the main menu, I've assigned the "TNet Network Manager" script and a "TNUdp Lobby Client". In the latter, I set the lobby server to my remote box's hostname (it's a Amazon Micro Win2K12) and made sure Windows Firewall allows the compiled binary (I took the one included with the UnityPackage and did some minor adjustments). Server ports are 31337, 31338 and 31339.

Here's what the current gameobject looks like. Hostname obscured for privacy/security reasons.

When clicking play, this comes out of the console:
  1. [TNet] Local IPs: 1
  2.   1: (Primary)
  3. UnityEngine.Debug:Log(Object)
  4. TNManager:Awake() (at Assets/TNet/Client/TNManager.cs:905)

Which I assume means that TNet is awake. Sometimes the UPNP Gateway says "Not found, can't open ports automatically", sometimes it's quiet, sometimes it reports back the gateway IP. Dunno if that's a issue with a stuck port, or what. Now, in the code...

  1. void Start() {
  2. TNManager.client.packetHandlers[(byte)Packet.ResponseChannelList] = OnChannelList;
  3. refreshHostList();
  4. }
  5. <....>
  6. void refreshHostList(){
  7. isBusy = true;
  8.         TNManager.client.BeginSend(Packet.RequestChannelList);
  9.         TNManager.client.EndSend();
  10. }
  12. void OnChannelList (Packet response, BinaryReader reader, IPEndPoint source){
  13.         Debug.Log("If you can see this, we have channels. Maybe.");
  14.         // The first integer represents the number of entries to follow
  15.         int channels = reader.ReadInt32();
  17.         // Read all incoming channel data
  18.         for (int i = 0; i < channels; ++i)
  19.         {
  20.             int id              = reader.ReadInt32();
  21.             int players         = reader.ReadUInt16();
  22.             int limit           = reader.ReadUInt16();
  23.             bool pass           = reader.ReadBoolean();
  24.             bool persistent     = reader.ReadBoolean();
  25.             string level        = reader.ReadString();
  26.             string data         = reader.ReadString();
  28.             // TODO: Do something with this data here
  29.         }
  30. isBusy = false;
  31. }
The OnChannelList code was pulled from here with a slight edit to see if TNet will actually get the stuff. However, it never says the Debug output.

I'm baffled at what I need to do. Do I need to use TNManager.Start(port) to start listening for info between the server and client? Or what am I missing? Note that a good chunk of the code is cut out because I'm not going to paste the entire script.

PRE-POST EDIT: Okay, so I switched to TCP Lobby Client and it seems to be better. However, on the server, I'm getting things like:
  1. <my public dev box IP>:<randomport> has connected.
  2. <my public dev box IP>:<randomport> has timed out.
  3. <my public dev box IP>:<randomport> has disconnected.
  4. <my public dev box IP>:<old port plus 2> has connected.
  5. <.....>

At least this output is better than nothing, that's for sure.
Can anyone provide pointers on what could possibly be going wrong?

TNet 3 Support / TNet: Network Level Loading
« on: September 21, 2014, 07:24:25 PM »

I'm one of the two guys working at [in]Sanity Interactive, a co-op game development crew that is currently working on a shooter project, which will feature both dedicated server and private matches where the player hosting the match is able to play as well. We have been using Unity's built-in framework (RakNet) and we've had troubles trying to get the network layer to work correctly when sending RPCs back to clients so they can load the right level.

I was wondering if you could confirm if TNet has server-instructed level loading capabilities, and if you could post a snippet of code that would be the basis of the server telling the client what to load.

When the player connects to the server hosting the game, before the client should do anything, the server sends a message (let's for arguments sake say "clientLoadLevel") to the client, with a string of it's level that is currently loaded (called from Application.levelLoadedName, etc). The client must then accept this message and start loading the level (I see TNet has TNet.LoadLevel which is nice!) otherwise I intend to kick the client saying "Wrong level loaded" to prevent really weird stuff happening.

So, in pseudo code:

Server: Client connects > Client, clientLoadLevel("mp_testlevel") > *waits for client response * > Okay, you've loaded, welcome to the game
Client: Connect to server from mainmenu > Server, what is the level? > Okay, I'll load mp_testlevel > Yay!

The thing here, is that in our current Unity RPC implementation, is that the RPC gets fired in a different scene since the server has loaded the level (let's say mp_testlevel) and since the client is on the main menu, it freaks out and errors or doesn't load the level and weird stuff starts happening.

So, this is one of the things I'm looking at in TNet. Plus, for shooters, I need a robust and reliable solution because I don't want major network glitches due to bugs in Unity's set-up. I realize that TNet is only the networking cake, and my game is the icing on top of that, but if you can confirm I can do the level loading as shown above, then you pretty much have a purchase.


Pages: [1]