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

Pages: [1]
1
TNet 3 Support / Using a Smartphone as a gamepad via TNet ?
« on: May 12, 2015, 05:03:26 AM »
Hi ArenMook & all other Tnet fans!

Idea:
  • 1 PC  with router & screen.
    This machine should be the host. Its purpose is to handle the inputs recived from the smartphones and apply and display it to the "game scene".
  • 2-8 smartphones connected via wifi.
    The smartphones only act as gamepads, showing a "virtual analogue stick scene".

In other words: i want to send input values from multiple smartphones to a pc that handles and displays the game.
Browsing the forum, i read that displaying different scenes(on smarphone: controller scene / on pc: actual game scene) causes problems  :(

What do i have to keep in mind or take care of for this special type of network implementation or why is it impossible?

Kind regards and thanks in advance!


2
TNet 3 Support / Unity Sample Assets beta third person controller + TNet
« on: February 25, 2014, 12:53:24 AM »
hey guys,

I'm currently playing around with the new sample assets (beta) from unity and i tried to create a fluid movement with the new third person controller.
i never worked with physics over the network till yet, so i thought it would be a good idea to learn this with the new assets since it uses rigidbody instead of character controller.
i couldn't figure out what i was doing wrong, but things looked like my first steps in networking when i was syncing transform positions  ::)

anyway, i removed the scripts and tried out the basic way to sync the movement vectors. the new scripts are well organised and the input is separated to the logic.
i couldn't believe my eyes when two lines of code almost did the job and now its a bit awkward to ask for help ::)

i basically only changed the move function to an RFC
  1. [RFC]
  2.         public void Move (Vector3 move, bool crouch, bool jump, Vector3 lookPos) {
  3.  
  4.                 if (move.magnitude > 1) move.Normalize();
  5.  
  6.                 // transfer input parameters to member variables.
  7.                 this.moveInput = move;
  8.                 this.crouchInput = crouch;
  9.                 this.jumpInput = jump;
  10.                 this.currentLookPos = lookPos;
  11.  
  12.                 // grab current velocity, we will be changing it.
  13.                 velocity = rigidbody.velocity;
  14.  
  15.                 ConvertMoveInput (); // converts the relative move vector into local turn & fwd values
  16.                
  17.                 TurnTowardsCameraForward (); // makes the character face the way the camera is looking
  18.  
  19.                 PreventStandingInLowHeadroom (); // so the character's head doesn't penetrate a low ceiling
  20.  
  21.             ScaleCapsuleForCrouching (); // so you can fit under low areas when crouching
  22.  
  23.                 ApplyExtraTurnRotation(); // this is in addition to root rotation in the animations
  24.                
  25.                 GroundCheck (); // detect and stick to ground
  26.  
  27.                 SetFriction (); // use low or high friction values depending on the current state
  28.  
  29.                 // control and velocity handling is different when grounded and airborne:
  30.                 if (onGround) {
  31.                         HandleGroundedVelocities();
  32.                 } else {
  33.                         HandleAirborneVelocities();
  34.                 }
  35.        
  36.                 UpdateAnimator (); // send input and other state parameters to the animator
  37.  
  38.                 // reassign velocity, since it will have been modified by the above functions.
  39.                 rigidbody.velocity = velocity; 
  40.  
  41.  
  42.         }

and extended the input script with the tno.send:

  1.                  
  2.                         [...]
  3.                         // pass all parameters to the character control script
  4.                         character.Move( move, crouch, jump, lookPos );
  5.                         tno.Send("Move", Target.OthersSaved, move, crouch, jump, lookPos);
  6.  


all inputs are applied correctly but it seems like there are some velocity issues. the synced clone shifts from walk to run about 2 seconds later than the original player, which leads to a huge position difference. i can't find the mistake  :-\
maybe one of you guys already played around with the new third person controller and have a solution.
i attach both scripts. thanks in advance!

3
TNet 3 Support / RFC Targeting
« on: November 11, 2013, 12:07:49 AM »
// see latest post

4
TNet 3 Support / identify/seek player via playerID
« on: October 30, 2013, 04:00:09 PM »
hey,

got some problems launching my sprint ability over the network.
situation is this:

one player activates "sprint" and passes his id in the RFC.
now every player including the 'sprinter' should set navmesh agent speed on the sprinting player to 12.
im not quite sure how to identify the player that activated sprint on the other players.

  1.  
  2. //player sends this when activate sprint
  3. tno.Send("enableSprint",Target.All,TNManager.playerID);
  4. /////
  5. //rfc
  6. ////
  7. @RFC
  8. function enableSprint(playerID_:int)
  9. {
  10.                 if(TNManager.playerID==playerID_)
  11.                 {
  12.                         gameObject.GetComponent(NavMeshAgent).speed=12;
  13.                         disableSprint(1);
  14.                 }
  15.        
  16.                                        
  17. }

this wount work because other players only check if they match the playerID_, right? how can i approach this? is there a way to find a gameObject where TNManager.playerID==playerID_ ?

best regards.

5
hey,

i searchd the forum first, but didnt get my mistake.
i get the error in my script. i have a script called applyCharCustom.js wich handles the look of the players avatar since i got multiple characters and skins and weapons available.
in start function i send all the players the visual style of the new player. everytime a new player joins everyone know how he should look. works like a charm.

  1. function Start(){
  2. tno=GetComponent(TNObject);
  3. if(tno.isMine)
  4. {
  5.         race=PlayerPrefs.GetInt("race");
  6.         skin=PlayerPrefs.GetInt("skin");
  7.         weaponHolder=PlayerPrefs.GetInt("weaponHolder");
  8.        
  9.         tno.Send("raceSwitch",Target.All,race);
  10.         tno.Send("weaponSwitch",Target.All,weaponHolder);
  11.         tno.Send("skinSwitch",Target.All,skin);
  12.         //raceSwitch();
  13.         //weaponSwitch();
  14.         //skinSwitch();
  15. }
  16. }
  17.  

problem is the code below. new players doesnt know how earlyr connected players look like, so my idea was to just use the OnNetworkPlayerJoin function to tell the new player how the others should look like. on this call i get the error. it works and the visual style is set correct, but after the error, the new player doesnt see animations on the others at all. :/

  1. function OnNetworkPlayerJoin(p:Player){
  2.  
  3.         tno.Send("raceSwitch",p,race);
  4.         tno.Send("weaponSwitch",p,weaponHolder);
  5.         tno.Send("skinSwitch",p,skin);
  6.  
  7. }


any idea?

6
TNet 3 Support / [Solved] Port Chat Example to UnityScript
« on: October 18, 2013, 07:24:20 AM »
hey, im currently porting the chat example to unityscript.

according to http://forum.unity3d.com/threads/79760-How-to-use-generics-in-unity-javascript and http://forum.unity3d.com/threads/12090-Defining-structures-in-unity-javascript its possible to use generics for the list<> stuff  and classes insteat of struct.

but exacly this does an error when compiling. maybe i did something wrong.
this is the error i got:
  1.  Ambiguous reference 'List': System.Collections.Generic.List.<ChatEntry>, TNet.List.<ChatEntry>.
  1. Ambiguous reference 'List': System.Collections.Generic.List.<TNet.Player>, TNet.List.<TNet.Player>.
  1. //------------------------------------------
  2. //            Tasharen Network
  3. // Copyright © 2012 Tasharen Entertainment
  4. //------------------------------------------
  5.  
  6.  
  7. import System.Collections.Generic;
  8. import UnityEngine;
  9. import TNet;
  10.  
  11. /// <summary>
  12. /// This example script shows how to create a chat window powered by the Tasharen Network framework.
  13. /// You can see it used in Example Chat.
  14. /// </summary>
  15. class ChatEntry
  16. {
  17.         var text:String;
  18.         var color:Color;
  19. }
  20. //[ExecuteInEditMode]
  21.  
  22.         var mRect:Rect;
  23.         var mName:String = "Guest";
  24.         var mInput:String = "";
  25.         var ChatStyle:GUISkin ;
  26.  
  27.  
  28.         var mChatEntries: List.<ChatEntry>  = new List.<ChatEntry>();
  29.  
  30.         /// <summary>
  31.         /// Add a new chat entry.
  32.         /// </summary>
  33.  
  34.         function AddToChat (text:String, color:Color)
  35.         {
  36.                 var ent:ChatEntry = new ChatEntry();
  37.                 ent.text = text;
  38.                 ent.color = color;
  39.                 mChatEntries.Add(ent);
  40.         }
  41.  
  42.         /// <summary>
  43.         /// The list of players in the channel is immediately available upon joining a room.
  44.         /// </summary>
  45.  
  46.         function OnNetworkJoinChannel (success:boolean, error:String)
  47.         {
  48.                 mName = TNManager.playerName;
  49.  
  50.                 var text:String = "Players here: ";
  51.                 var players:List.<Player> = TNManager.players;
  52.                
  53.                 for (var i = 0; i < players.size; ++i)
  54.                 {
  55.                         if (i > 0) text += ", ";
  56.                         text += players[i].name;
  57.                         if (players[i].id == TNManager.playerID) text += " (you)";
  58.                 }
  59.                 AddToChat(text, Color.black);
  60.         }
  61.  
  62.         /// <summary>
  63.         /// Notification of a new player joining the channel.
  64.         /// </summary>
  65.  
  66.         function OnNetworkPlayerJoin (p:Player)
  67.         {
  68.                 AddToChat(p.name + " has joined the channel.", Color.black);
  69.         }
  70.  
  71.         /// <summary>
  72.         /// Notification of another player leaving the channel.
  73.         /// </summary>
  74.  
  75.         function OnNetworkPlayerLeave (p:Player)
  76.         {
  77.                 AddToChat(p.name + " has left the channel.", Color.black);
  78.         }
  79.  
  80.         /// <summary>
  81.         /// Notification of a player changing their name.
  82.         /// </summary>
  83.  
  84.         function OnNetworkPlayerRenamed ( p:Player,  previous:String)
  85.         {
  86.                 AddToChat(previous + " is now known as " + p.name, Color.black);
  87.         }
  88.  
  89.         /// <summary>
  90.         /// This is our chat callback. As messages arrive, they simply get added to the list.
  91.         /// </summary>
  92.  
  93.         @RFC
  94.         function OnChat (playerID:int, text:String)
  95.         {
  96.                 // Figure out who sent the message and add their name to the text
  97.                 var player:Player = TNManager.GetPlayer(playerID);
  98.                 var color:Color = (player.id == TNManager.playerID) ? Color.green : Color.white;
  99.                 AddToChat("[" + player.name + "]: " + text, color);
  100.         }
  101.  
  102.         /// <summary>
  103.         /// Send the typed message to the server and clear the text.
  104.         /// </summary>
  105.  
  106.         function Send ()
  107.         {
  108.                 if (!String.IsNullOrEmpty(mInput))
  109.                 {
  110.                         tno.Send("OnChat", Target.All, TNManager.playerID, mInput);
  111.                         mInput = "";
  112.                 }
  113.         }
  114.  
  115.         /// <summary>
  116.         /// This function draws the chat window.
  117.         /// </summary>
  118.  
  119.         function OnGUI ()
  120.         {
  121.                 if(ChatStyle)
  122.                 {
  123.                         GUI.skin=ChatStyle;
  124.                 }
  125.                
  126.                 //float cx = Screen.width * 0.5f;
  127.                 //float cy = Screen.height * 0.5f;
  128.  
  129.         //      GUI.Box(new Rect(Screen.width * 0.5f - 270f, Screen.height * 0.5f - 200f, 540f, 410f), "");
  130.  
  131.         /*      GUI.Label(new Rect(cx - 140f, cy - 170f, 80f, 24f), "Nickname");
  132.                 GUI.SetNextControlName("Nickname");
  133.                 mName = GUI.TextField(new Rect(cx - 70f, cy - 170f, 120f, 24f), mName);
  134.  
  135.                 if (GUI.Button(new Rect(cx + 60f, cy - 170f, 80f, 24f), "Change"))
  136.                 {
  137.                         // Change the player's name when the button gets clicked.
  138.                         TNManager.playerName = mName;
  139.                 }*/
  140.  
  141.                 GUI.SetNextControlName("Chat Window");
  142.                 mRect = new Rect(0, Screen.height-400, 400f, 300f);
  143.                 GUI.Window(0, mRect, OnGUIWindow, "");
  144.  
  145.                 if (Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyUp)
  146.                 {
  147.                         var ctrl:String = GUI.GetNameOfFocusedControl();
  148.  
  149.                         if (ctrl == "Nickname")
  150.                         {
  151.                                 // Enter key pressed on the input field for the player's nickname -- change the player's name.
  152.                                 TNManager.playerName = mName;
  153.                                 GUI.FocusControl("Chat Window");
  154.                         }
  155.                         else if (ctrl == "Chat Input")
  156.                         {
  157.                                 Send();
  158.                                 GUI.FocusControl("Chat Window");
  159.                         }
  160.                         else
  161.                         {
  162.                                 // Enter key pressed -- give focus to the chat input
  163.                                 GUI.FocusControl("Chat Input");
  164.                         }
  165.                 }
  166.         }
  167.  
  168.         /// <summary>
  169.         /// This function draws the chat window and the chat messages.
  170.         /// </summary>
  171.  
  172.         function OnGUIWindow (id:int)
  173.         {
  174.                 GUI.SetNextControlName("Chat Input");
  175.                 mInput = GUI.TextField(new Rect(6, mRect.height - 30, 328, 24), mInput);
  176.  
  177.                 if (GUI.Button(new Rect(334, mRect.height - 31, 60, 26), "Send"))
  178.                 {
  179.                         Send();
  180.                         GUI.FocusControl("Chat Window");
  181.                 }
  182.  
  183.                 GUI.BeginGroup(new Rect(2, 20, 382, 254));
  184.                 //{
  185.                         var rect:Rect = new Rect(4, 244, 382, 300);
  186.  
  187.                         for (var i = mChatEntries.size; i > 0; )
  188.                         {
  189.                                 var ent:ChatEntry = mChatEntries[--i];
  190.                                 rect.y -= GUI.skin.label.CalcHeight(new GUIContent(ent.text), 382);
  191.                                 GUI.color = ent.color;
  192.                                 GUI.Label(rect, ent.text, GUI.skin.label);
  193.                                 if (rect.y < 0) break;
  194.                         }
  195.                         GUI.color = Color.white;
  196.                 //}
  197.                 GUI.EndGroup();
  198.         }
  199.  
  200.  


-----------------------------------
Solved:

Problem was both ( TNet and System.Collections.Generic ) has a List<>. this caused the error.
i deletet the import of System.Collections.Generic and only worked with System.Collections.Generic.List.<ChatEntry>  instead.

7
TNet 3 Support / [Solved] Animation RFC
« on: October 15, 2013, 09:43:43 AM »
hey,

little problem here. i try to sync position and rotation and animation over network. so each player see's the others move correctly.
my problem is: all actions that other players do, trigger the animations on the player that first joined while position and rotation are syncd correctly.

this is the lower end of my charactercontroller script:
  1. ....
  2. ....
  3. ....
  4.  
  5.  
  6. switch(moveStatus)
  7.     {
  8.         case "idle":
  9.                                         if(!animCon.animation.IsPlaying("Attack02"))
  10.                                         animCon.animation.CrossFade("Idle")
  11.                                         ;break;
  12.         case "jump":
  13.                                 //      if(!animCon.animation.IsPlaying("Attack02"))
  14.                                         animCon.animation.CrossFade("Idle");
  15.                                         break;
  16.         case "walking":
  17.                                         //if(!animCon.animation.IsPlaying("Attack02"))
  18.                                         animCon.animation.CrossFade("Run");
  19.                                         break;
  20.         case "running":
  21.                                         //if(!animCon.animation.IsPlaying("Attack02"))
  22.                                         animCon.animation.CrossFade("Run");
  23.                                         break;
  24.         case "sidewalking_r":
  25.                                         //if(!animCon.animation.IsPlaying("Attack02"))
  26.                                         animCon.animation.CrossFade("Run");
  27.                                         break;
  28.         case "siderunning_r":
  29.                                         //if(!animCon.animation.IsPlaying("Attack02"))
  30.                                         animCon.animation.CrossFade("Run");
  31.                                         break;
  32.         case "sidewalking_l":
  33.                                         //if(!animCon.animation.IsPlaying("Attack02"))
  34.                                         animCon.animation.CrossFade("Run");
  35.                                         break;
  36.         case "siderunning_l":
  37.                                         //if(!animCon.animation.IsPlaying("Attack02"))
  38.                                         animCon.animation.CrossFade("Run");
  39.                                         break;
  40.         case "backwalking":
  41.                                         //if(!animCon.animation.IsPlaying("Attack02"))
  42.                                         animCon.animation.CrossFade("Run");
  43.                                         break;
  44.                                        
  45.         case "backrunning":
  46.                                         //if(!animCon.animation.IsPlaying("Attack02"))
  47.                                          animCon.animation.CrossFade("Run");
  48.                                          break;
  49.         case "melee_attack":
  50.                                         animCon.animation.Play("Attack02");
  51.                                         break;
  52.         case "dead":    
  53.                                         if(deadRepAnim)
  54.                                         return;
  55.                                         Debug.Log("Dead anim");
  56.                                         animCon.animation.Play("Dead");
  57.                                         deadRepAnim=true;
  58.                                         break;  
  59.     }
  60.    
  61.     //Send animations
  62.     tno.Send("PlayAnimation", Target.All,transform.position, transform.rotation, moveStatus);
  63. }//tno.isMine  
  64. }//Update
  65.  
  66. @RFC
  67. function PlayAnimation(pos:Vector3, rot:Quaternion,animation:String){
  68.    
  69.    transform.position=pos;
  70.    transform.rotation=rot;
  71.    moveStatus=animation;
  72. }


Pages: [1]