Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: NeilM on February 04, 2016, 05:13:05 PM

Title: TNet 3 Tutorials
Post by: NeilM on February 04, 2016, 05:13:05 PM
Hi, I'm the new guy here at Tasharen and over the past little while I've been writing tutorials for the latest version of TNet.

I would be interested in any feedback that you guys might have on the existing ones and if you have any tutorials you would like to see, please let me know.

Overview

Examples Overview (https://docs.google.com/document/d/1FPCPCW7iM_lGnGkWkaPkyAi66rRJa6mrKCla_-98Nu8)

In-Depth

Example AutoJoin (https://docs.google.com/document/d/1QSAUHc6Z5U82KPuA4k6GS4H7fKMBBu1rcb0d3SPcIb4/edit?usp=sharing)
Example AutoSync (https://docs.google.com/document/d/1YdVmGk9gubX8kpL7HxDXesBLsMdr8Jk4TMeGBZQqzMM/edit?usp=sharing)
0. Menu (https://docs.google.com/document/d/14sxvHaJS_Hj4xFEqh_6MfsJuKn7WA75tLZ2m7r0bNOI/edit?usp=sharing)
1. RFCs (https://docs.google.com/document/d/1Ulv59pfZmjcMyiyORsah34S0smlNDxbnP2fPqkQ0uH8)
2. Object Creation (https://docs.google.com/document/d/1i-2VoVJzQjoxbMP12HALZ0mqp1Vhq_fF3tIKvEyfKRM)
3. Frequent Packets (https://docs.google.com/document/d/1SbXpmqXk9dKEfnTSV-ytvJST8ZRALYu1tT2cG1wPSVU)
4. Chat (https://docs.google.com/document/d/1h4GHx67gmc3fkjkcNAy6gWDW7TGaIDdcON0p5P9fUJo/edit?usp=sharing)
5. Movement (https://docs.google.com/document/d/1QLh4ygaAGo0MvFaARNm9d6ZTsy6mbTOFlW0oMa-R1Eo/edit?usp=sharing)
6. Multiple Channels (https://docs.google.com/document/d/1uYOzJsoglfclz1yue3-YrGMGlw_qC0DOIOxLnCVp9lU/edit?usp=sharing)

Other Tutorials

Instantiating Objects With Parameters (https://docs.google.com/document/d/1JjPip_J_uWFvc-SZ9NR_pwPr3dIoAc7PQd1aCevor2U/edit?usp=sharing)
Synchronizing and Saving Player Data (https://docs.google.com/document/d/1WZlIppbYy4CiPbm24Fa4AfZkjXmtKIZEMas94NxrnDY/edit?usp=sharing)
Custom Channel Data (https://docs.google.com/document/d/1AtEHMNS8Ltqjjn3vZSw7t7AW8UJexhqVZpk0VV90k-c/edit?usp=sharing)
Using the DataNode structure (https://docs.google.com/document/d/1JDpL25vR0NL3A43C8T_hE8MMX4dSYH4G8u87L3ozIik/edit?usp=sharing)
Executing Runtime C# Code (https://docs.google.com/document/d/1Wd-5S68EeVSLBD5PXEsuJVnPwXYgY6irEH0qYwRDmTw/edit?usp=sharing)
Runtime C# Behaviours (https://docs.google.com/document/d/1yGcKsbTQuinYaUmfT_7HpaqDeJUoLjqzUARdG1isAjs/edit?usp=sharing)
Worker Thread class (http://www.tasharen.com/forum/index.php?topic=14776.0) -- offloading the processing onto other CPU cores the easy way

Beginner's Video Tutorial: https://www.youtube.com/watch?v=7oBhEwAHU5w
Class Documentation: http://www.tasharen.com/tnet/docs/

Frequently Asked

Channel Discovery (http://www.tasharen.com/forum/index.php?topic=14198.0)
Title: Re: TNet Tutorials
Post by: gevarre on February 04, 2016, 05:35:03 PM
Awesome start :)
Title: Re: TNet Tutorials
Post by: devomage on February 05, 2016, 05:55:26 PM
1.  Multiple character controllers.  Based on input (not position) per posts by Aren.  Unity standard asset - bonus for UFPS.
2.  Syncing character controller animations.
Title: Re: TNet Tutorials
Post by: phoenix on February 06, 2016, 09:04:24 PM
I would also suggest some tutorials for DataNodes and the new serialization system
Title: Re: TNet Tutorials
Post by: nosyrbllewe on February 06, 2016, 11:18:35 PM
I concur with @devomage suggestions, especially for UFPS.
Title: Re: TNet Tutorials
Post by: NeilM on February 09, 2016, 12:30:06 PM
Feb 9th 2016 Changes:

- "Synchronizing and Saving Player Data" has been updated to use the new TNManager.SetPlayerData function.
- "Custom Channel Data" has been updated to use the new TNManager.SetChannelData function.
Title: Re: TNet Tutorials
Post by: NeilM on February 09, 2016, 12:30:50 PM
@devomage - There is a new car driving example in TNet (called Movement) which demonstrates how to frequently send player inputs, and once and a while update the exact transform and rigidbody of a character.

As for animations, syncing animations can be done by following the "Synchronizing and Saving Player Data" tutorial and instead of setting a materials colour, set a trigger/int/float on the animator.
Title: Re: TNet Tutorials
Post by: NeilM on February 09, 2016, 12:35:02 PM
@phoenix - The dataNodes are demonstrated in the "Synchronizing and Saving Player Data (https://docs.google.com/document/d/1WZlIppbYy4CiPbm24Fa4AfZkjXmtKIZEMas94NxrnDY/edit?usp=sharing)" tutorial.  It passes a single Color variable across the network using dataNodes.
Title: Re: TNet Tutorials
Post by: phoenix on February 09, 2016, 08:18:53 PM
I see this line
TNManager.onSetPlayerData = delegate(Player p, string path, DataNode node)
and then this
TNManager.SetPlayerSave(SystemInfo.deviceUniqueIdentifier + "/Player.dat");

Is the DataNode connected to the player.dat?


Then I see
void OnSetPlayerData(Player p, string path, DataNode node)

Does the Player p need to have a DataNode game object ?

How does the p.Get and the DataNode connect together?

Why is the DataNode within the Delegate it does not look like it is used?

How can I pull different types of data out of the DataNode like a serialized dictionary or a class or a full prefab game object?
Title: Re: TNet Tutorials
Post by: ArenMook on February 10, 2016, 04:48:45 PM
TNManager.onSetPlayerData sets the function that will be called when player update packets arrive. These packets are sent as a result of someone calling TNManager.SetPlayerData, but can also be sent from TNManager.SetPlayerSave.

TNManager.SetPlayerSave basically tells the server what file to use for that player's saves. It will load the data stored in that file (player.dat) and will ultimately result in onSetPlayerData being called with the parsed data's root node being passed as the DataNode parameter. SetPlayersave will also mean that the player's data will be saved to that file every time that player calls TNManager.SetPlayerData.

When you call TNManager.SetPlayerData("path/to/node", value), you pass a path. DataNode is like a file system -- it can have children just like files and folders. When you get an onSetPlayerData notification back, it will pass the "path/to/node" back to all players, along with the actual node at that pah -- same node you would get if you were to do player.Get("path/to/node"). You don't have to use this node if you don't want to. It's just there in case you do in order to save an extra lookup.

Player.Get just calls player.dataNode.GetHierarchy. It's a convenience function for you.

Pulling different types of data can be done via player.Get<type>("path/to/node"), or -- as the paragraph above explains -- player.dataNode.GetHierarchy<type>("path/to/node"). It's just shorter to use the convenience method. Same convenience method exists on the channel as well. You can do channel.Get<type>("path/to/node").
Title: Re: TNet Tutorials
Post by: NeilM on February 10, 2016, 05:00:40 PM
Just to clarify the delegate a little more:

  1. void OnSetPlayerData(Player p, string path, DataNode node)

p is the player and it contains all of the dataNodes associated with this player.
path is the path to the one variable which was set.  In the example it's "Color", but it could be "my/custom/path/Color"
node is the one dataNode which changed.  eg. Color = (1.0, 0.0, 1.0, 1.0)

The example ignores the second two variables, but the node could have just as easily been used in conjunction with a case/if statement if there was more than one potential value to be set.
Title: Re: TNet Tutorials
Post by: NeilM on February 12, 2016, 05:01:01 PM
- Adjusted all of the tutorials to use the new callback functionality now that broadcasts have been removed.
- Added an in-depth review of the Chat example.
- Added an in-depth review of the Movement example.
Title: Re: TNet Tutorials
Post by: NeilM on February 17, 2016, 05:22:10 PM
* Example AutoJoin - has been added.
* Example AutoSync - has been added.
* 0. Menu - has been added and details how to start a lobby server.
* 5. Movement - has been rewritten as the scripts have changed.
* 6. Multiple Channels - has been rewritten as the scripts have changed.
Title: Re: TNet Tutorials
Post by: NeilM on February 22, 2016, 02:49:28 PM
Title: Re: TNet 3 Tutorials
Post by: chiuan on February 25, 2016, 10:32:32 AM
 :) cool network framework for unity
Title: Re: TNet 3 Tutorials
Post by: NeilM on February 26, 2016, 03:03:01 PM
We've added some more advanced tutorials on how to inject C# code into your game at runtime.  This is useful for enabling modding of your game.


Title: Re: TNet Tutorials
Post by: devomage on March 11, 2016, 05:13:50 AM
  • Added a new DataNode document

It would be great if you could extend this to include Enum, Struct or a custom class.  For example, what if TNet.Packet was a variable in a Datanode?

Great job on the tutorials!  Very thorough.
Title: Re: TNet 3 Tutorials
Post by: ArenMook on March 11, 2016, 07:52:42 AM
DataNode can serialize all enums, structs and custom classes natively just by using reflection. You can add IBinarySerializable to your class to create a more custom version of the serialization code and control what gets serialized (or just mark fields with [IgnoredByTNet]). You can also create extension methods for classes you can't extend. Look at TNUnitySerializers.cs -- Serialize/Deserialize functions for a bunch of Unity classes in there such as MeshFilter and Renderer.
Title: Re: TNet 3 Tutorials
Post by: MrSkyhenge on March 23, 2016, 03:41:08 AM
Are there any plans for future tutorials and examples? Just checking since there doesn't seem to have been any movement on this topic in a while.
Title: Re: TNet 3 Tutorials
Post by: ArenMook on March 24, 2016, 03:11:15 AM
Is there anything in particular you would like to see / know more about?
Title: Re: TNet 3 Tutorials
Post by: Bradamante3D on March 27, 2016, 03:57:08 PM
Executing Runtime C# Code (https://docs.google.com/document/d/1Wd-5S68EeVSLBD5PXEsuJVnPwXYgY6irEH0qYwRDmTw/edit?usp=sharing)
Runtime C# Behaviours (https://docs.google.com/document/d/1yGcKsbTQuinYaUmfT_7HpaqDeJUoLjqzUARdG1isAjs/edit?usp=sharing)

Hm, downloading TNet 3 from the Asset Store these two documents are not included in PDF form. They will be included in the future?
Title: Re: TNet 3 Tutorials
Post by: ArenMook on March 27, 2016, 06:16:34 PM
Yup, I will add them.
Title: Re: TNet 3 Tutorials
Post by: ArenMook on April 09, 2016, 09:00:25 AM
Well, a reason to update then ;)
Title: Re: TNet 3 Tutorials
Post by: tstack on April 29, 2016, 08:52:11 AM
Getting back to the tutorial input, is there any chance that either the Space Game or Ship Game Starter Kits would be updated for TNet 3 and made available again?

http://www.tasharen.com/?page_id=53
http://www.tasharen.com/?page_id=62

I feel that a lot of what I stumble on is probably pretty close to what is / was in these kits, and they'd prove a better example for what I am working on.

Alternatively - is it possible still to buy the old version anywhere? Updating 2->3 code is also a great way to learn.

Thanks
Title: Re: TNet 3 Tutorials
Post by: ArenMook on April 29, 2016, 12:28:25 PM
@xzkmxd: I don't understand what you're asking, but I am pretty sure it has nothing to do with tutorials. Please start a new thread instead of cluttering this one.

@tstack: I'll be releasing a Space Game Starter Kit 2, featuring planetary terrain generation and atmospheric rendering I covered in the dev blog (http://www.tasharen.com/forum/index.php?board=15.0). I currently don't have plans to update the ship starter kit, and it never supported TNet anyway. Starlink UI was already updated with TNet 3 support.