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 - addebooi

Pages: [1]
1
TNet 3 Support / Change player name in OnNetworkConnect or near.
« on: November 11, 2013, 06:56:10 AM »
Hey! i got a script so when he connects to the server it calls "OnNetworkConnect", and that works just fine. But then i want to change the player name in that function, and apparently that wont work
  1.  
  2. void OnNetworkConnect(bool succes, string message){
  3.         if(succes){
  4.                 Debug.Log("Playername before: " + TNManager.playerName);
  5.                 TNManager.playerName = "ChangedName";
  6.                 Debug.Log("Playername after: " + TNManager.playerName);
  7.                 loadMenu();
  8.         }
  9.         else{
  10.                 Debug.Log("there was an error: " + message);
  11.                 onFailedConnection();
  12.         }
  13. }
  14.  
The name is both Guest before and after the change.
Ive also tested making the name change upon start in the menu that loads
  1.  
  2. void Start(){
  3.         Debug.Log(TNManager.playerName);
  4.         TNManager.playerName = "ChangedName";
  5.         Debug.Log(TNManager.playerName);
  6. }
  7.  
And both here returns Guest.
Then i tested making an Coroutine with a delay by 0.1 seconds, then change the name(in the start function of the menu), Then it works just fine! Is it really neccisary to have a delay for changing name of the player?

2
TNet 3 Support / Are the clients sharing OnNetworkJoinChannel?
« on: November 09, 2013, 07:20:56 PM »
Hey! ive got a small problem here... When i call the "OnNetworkJoinChannel(bool succes, string message)"

What i do in this function is: listOfPlayerInLobby = TNManager.players; which mean when I(the client who joined), joines the channel, get all the players currently in there and put it in a list.
Apparently, every time i call this when a players joins, it sets the list on everyone connected insteed on only himself, which is a wierd behaviur. Ive done debug.logs in there, but when a player joins so doesn't it write anything.

3
TNet 3 Support / Trying to retriew channels, but crashes sometimes
« on: November 09, 2013, 05:41:39 AM »
So what ive done is that ive looked on previusly forums and tried to make some kind off menu off it:
  1. TNManager.BeginSend(Packet.RequestChannelList);
  2. TNManager.client.packetHandlers[(byte)Packet.ResponseChannelList] = OnChannelList;
  3. TNManager.EndSend();
  4.  
This is the code i run to retriew my "list" that would say
  1. listOfCurrentlyLobby = new List<menuJoinChanelClass>();
  2.                 int count = reader.ReadInt32();
  3.                 int channelIDD = 0;
  4.                 int playerCount = 0;
  5.                 bool hasPassword = false;
  6.                 bool isPersistent = false;
  7.                 string levelName = "";
  8.                
  9.                 for(int i = 0; i<count;i++){
  10.                        
  11.                         channelIDD = reader.ReadInt32();
  12.                         playerCount = reader.ReadInt32();
  13.                         hasPassword = reader.ReadBoolean();
  14.                         isPersistent = reader.ReadBoolean();
  15.                         levelName = reader.ReadString();
  16.                         listOfCurrentlyLobby.Add(new menuJoinChanelClass(channelIDD,playerCount,hasPassword,isPersistent,levelName));
  17.                 }
  18.  

And that's pretty much all code ive written to retriew a list for the client, sometimes it pretty much works, the client retriews a channel with id's and such, but mostly both keeps getting dced and i don't onestly know why, it ain't coming up and errorss in unity, But in tnServeri keep getting: "Timed out". Any help would be appriciated, don't really know what ive done wrong! :)

4
TNet 3 Support / Make the server host
« on: October 15, 2013, 09:09:54 AM »
Is there anyway to make the server computer host for any channel that is created?

5
TNet 3 Support / using linq with TNet
« on: October 11, 2013, 05:16:09 PM »
I came up with a problem here. i want to use a Linq allgorithm to find a specifik item in a Tnet list. But apparently Linq don't support the Tnet list.. How do i come by this?
If there is no way for coming by this: how do i make a similiar for list.find(x=>x.item == item)? or something like that

6
TNet 3 Support / TnObjects
« on: October 11, 2013, 02:57:49 AM »
Hey, i was considering creating an object named "hostManager" and preset it in the scene with a don't destory on load. The only problem is that it can't send "tno.send". Is that becouse it has the ID 0 becouse it's static or something? becouse other players aint receiving RFC from that objec when sent it.
So my question is: Do i have to spawn the object through tnmanager.Create for beeing able to use the tno.Send??

7
TNet 3 Support / Ping player & setting host
« on: October 09, 2013, 12:26:29 PM »
Hello! I was thinking a a system that when a player join so call the "OnNetworkPlayerJoin" which takes a parameter "Player". so when the player joins so will the current host check with every client currently conencted to the current channel for their Ping and if someone has a better ping so will he be the new "host".
Why i want to do that is becouse if someone with a bad ping is host for around 20 players, and the host is sending RPC and all from the AI so will the game be slower for the rest of the players.
Was checking around the unity forum and came along this: http://docs.unity3d.com/Documentation/ScriptReference/Network.GetAveragePing.html , and apparently the TNET.player and the Unitys Network player aint the same. So is their any way for checking theirs ping and or determine a new host for a channel

8
TNet 3 Support / Joining channel, stay in same position
« on: October 07, 2013, 05:09:37 PM »
Ive noticed some buggs when i try to make a "channal" changeing script. It's 2 clients who are in the same channel and scene. then theres a script that looks like this:
  1. public class changeChannel : MonoBehaviour {
  2.        
  3.         void OnGUI(){
  4.                 if(GUI.Button(new Rect(20,20,100,40),"1")){
  5.                         joinChannel(1);
  6.                 }
  7.                 if(GUI.Button(new Rect(20,80,100,40),"2")){
  8.                         joinChannel(2);
  9.                 }
  10.         }
  11.        
  12.         void joinChannel(int channelID){
  13.                 TNManager.JoinChannel(channelID,null);
  14.         }
  15. }
verry simple, i make the joinchannel level to null so you don't have to respawn at a new position everytime i join that channal, I wan't to make so everyone loads me in when i join the channel and the same thing goes for me, when i join the channel: load every objects in that channel. The reason why i dont wan't to load a level is becouse you should be able to walk
into zones and keep your current position while entering a new channel
What happens when i change the channel:
1. The player who presses change channel still have the old game objects "may be a reason for none level load.. I dunno".
2. THe player that pressed channel change dissapears for the rest of the players in the old channel.
3. The player that leaves the old channel and joins an empty can walk around and wont respawn(as wanted), but when the player enters the channel with players on it so will he respawn.
I'm using the script TNAutoCreate and then the player is inside it

9
TNet 3 Support / Charactercontroller movement
« on: October 06, 2013, 05:16:06 PM »
Ive been watching your vedeo tutorial for getting started, and ive decided to use the charactercontroller attach to the player object instead and write som script for that. How am i supose to link it's position trhough RFC? In the tutorial you send the destination to the gameobject the player is controlling and in that way the client that recieved the RFC can move that gameobject by itself, but if the player make alot of movements, and the "destination" can't be predicted?
Thanks in forhand :)!

Pages: [1]