Hey, so I'm really new to TNet and I'm have some real trouble grasping how everything works haha. I made a really simple project to practice in which all that happens is that you can start a sever or join a server. When you do I simply want the console to say "Player joined server" or something. This is the scripts:
Main menu script:
using UnityEngine;
using TNet;
using System.IO;
using System.Collections;
using UnityTools = TNet.UnityTools;
using UnityEngine.UI;
public class Network_Manager : MonoBehaviour {
public string SPSceneName;
public string inputIP;
public bool connected;
public Text ipTextField;
public int serverTcpPort = 5127;
void Update()
{
inputIP = ipTextField.text;
}
void Start()
{
ipTextField.text = Tools.externalAddress.ToString();
if (Application.isPlaying)
{
// Make it possible to use UDP using a random port
TNManager.StartUDP(Random.Range(10000, 50000));
}
}
public void Quit_Button()
{
Application.Quit();
}
public void Create_Server()
{
int udpPort = Random.Range(10000, 40000);
TNServerInstance.Start(serverTcpPort, udpPort);
if (TNManager.isHosting)
{
print("Hosting server.");
TNManager.LoadLevel("Game");
}
}
public void Join_Server()
{
TNManager.Connect(inputIP);
if (TNManager.isTryingToConnect)
{
print("Trying to connect...");
}
}
void OnNetworkConnect(bool success, string message)
{
if (success)
{
TNManager.JoinChannel(123, SPSceneName);
print("Connected!");
success = true;
}
else
{
success = false;
print(message);
}
}
}
and this is the game scene script:
using UnityEngine;
using System.Collections;
using TNet;
public class PlayerJoin : TNBehaviour
{
private void Start()
{
tno.Send("PlayerJoin", Target.All);
}
[RFC]
public void PlayerJoin()
{
Debug.Log("Player joined game");
}
}
Unfortunately none of this works, Any idea why?