Author Topic: TNet 3 Tutorials  (Read 46790 times)

NeilM

  • Global Moderator
  • Newbie
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 7
  • Posts: 16
    • View Profile
TNet 3 Tutorials
« 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

In-Depth

Example AutoJoin
Example AutoSync
0. Menu
1. RFCs
2. Object Creation
3. Frequent Packets
4. Chat
5. Movement
6. Multiple Channels

Other Tutorials

Instantiating Objects With Parameters
Synchronizing and Saving Player Data
Custom Channel Data
Using the DataNode structure
Executing Runtime C# Code
Runtime C# Behaviours
Worker Thread class -- 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
« Last Edit: August 01, 2016, 02:57:33 PM by ArenMook »

gevarre

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: TNet Tutorials
« Reply #1 on: February 04, 2016, 05:35:03 PM »
Awesome start :)

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: TNet Tutorials
« Reply #2 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.

phoenix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 49
    • View Profile
Re: TNet Tutorials
« Reply #3 on: February 06, 2016, 09:04:24 PM »
I would also suggest some tutorials for DataNodes and the new serialization system

nosyrbllewe

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 11
    • View Profile
Re: TNet Tutorials
« Reply #4 on: February 06, 2016, 11:18:35 PM »
I concur with @devomage suggestions, especially for UFPS.

NeilM

  • Global Moderator
  • Newbie
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 7
  • Posts: 16
    • View Profile
Re: TNet Tutorials
« Reply #5 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.

NeilM

  • Global Moderator
  • Newbie
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 7
  • Posts: 16
    • View Profile
Re: TNet Tutorials
« Reply #6 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.

NeilM

  • Global Moderator
  • Newbie
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 7
  • Posts: 16
    • View Profile
Re: TNet Tutorials
« Reply #7 on: February 09, 2016, 12:35:02 PM »
@phoenix - The dataNodes are demonstrated in the "Synchronizing and Saving Player Data" tutorial.  It passes a single Color variable across the network using dataNodes.

phoenix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 49
    • View Profile
Re: TNet Tutorials
« Reply #8 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNet Tutorials
« Reply #9 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").

NeilM

  • Global Moderator
  • Newbie
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 7
  • Posts: 16
    • View Profile
Re: TNet Tutorials
« Reply #10 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.

NeilM

  • Global Moderator
  • Newbie
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 7
  • Posts: 16
    • View Profile
Re: TNet Tutorials
« Reply #11 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.

NeilM

  • Global Moderator
  • Newbie
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 7
  • Posts: 16
    • View Profile
Re: TNet Tutorials
« Reply #12 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.

NeilM

  • Global Moderator
  • Newbie
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 7
  • Posts: 16
    • View Profile
Re: TNet Tutorials
« Reply #13 on: February 22, 2016, 02:49:28 PM »
  • Added a new DataNode document

chiuan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 6
  • Posts: 11
    • View Profile
Re: TNet 3 Tutorials
« Reply #14 on: February 25, 2016, 10:32:32 AM »
 :) cool network framework for unity