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.


Messages - krvc

Pages: [1] 2
1
TNet 3 Support / Cant clear channel data after player exit
« on: January 12, 2017, 12:43:08 PM »
hi. my players sometimes write data on channel. (example tno.isMine TNManager.SetChannelData("info", +1);)
i cant find good way how clear it. (players lose connection or use alt+f4 to exit from game)

1.  i create empty "sample object" and write data to it. (TNManager.Instantiate FALSE)
then players off - object destroy, and i use code in Destroy() void - every players send ("info", -1) - wrong result.....

2. i added if tno.isMine - sometimes clear info, sometimes no... (players lose connection or use alt+f4 to exit from game)

3. okay i create new object (TNManager.Instantiate TRUE) for ONE player - its my virtual host. it player clear data other players.
yes, now data others players clear a good. Then player a leave object change owner to next player, object have tno.isMine
and clear data for One player, but sometimes its clearing data for new Owner too...

2
TNet 3 Support / Game logic
« on: November 20, 2016, 11:10:08 PM »
How to create game?

1. channels
    i think need main Channel and Game channels.
   Game channel must have flag persistens  = false

2. neutral monster
   i think it need TNManager.Instantiate, and must have flag persistens  = true
   if player leave, monsters not.

3. Data sending
    Game need send data to players.
                                                Q: what better way, use RFC or set get channel data?

4. Game time.
   Game need time. i think time must send only 1 player. Need create Empy obj+TNO whith script and check if tno.isMine, when send time to all Players.

5. create players...
    oh... its a problem, my prefab have position 0*0*0, but all players have not One spawn position. if i create player in pos much more >0*0*0, when player create in not my position.
    it Transform t = go.transform; have conflict whith NavMesh component....
    i solved it problem to create prefabs for all players  p1 20*20*20  p2 40*40*40, etc...


   

3
TNet 3 Support / Re: Need simple example to save channel data
« on: November 03, 2016, 03:14:56 AM »
I think i not connected... Try to set data after  TNManager.JoinChannel(0, firstLevel, persistent, 10000, null);. Maybe  TNManager.JoinChannel need time.
Thanks.

4
TNet 3 Support / Re: Need simple example to save channel data
« on: November 03, 2016, 01:16:57 AM »
   try to count players on channel or something else, but something wrong
       
                int playersCounter;
                playersCounter = TNManager.GetChannelData<int>(0, "playersOnServer") +1;
                TNManager.SetChannelData(0, "playersOnServer", playersCounter);
                print("1counterSet" + playersCounter);

                playersCounter = TNManager.GetChannelData<int>(0, "playersOnServer");
                print("2counterGet" + playersCounter);

print1 = 1  print2 = 0

5
TNet 3 Support / Re: Need simple example to save channel data
« on: October 27, 2016, 02:11:42 AM »
Hmm.. i think i not needed all time save channel data in server.
I need added "IF" and check empty data or not when connect to channel, if empty then again Write.
Thanks.

6
TNet 3 Support / Need simple example to save channel data
« on: October 26, 2016, 07:07:20 AM »
Hi, i connect to my project with TNAutoJoin. I change "public bool persistent"  to "true";

I create 2 buttons - Set version and Get version. I save info TNManager.SetServerData, it saved, but all my players need to save data, and i change it to SetChannelData, it save too, but after i disconnect all data a missing.... (not saving)


using UnityEngine;
using System.Collections;
using TNet;

public class GameVersion : MonoBehaviour {
    private int checkVersion;
   
    //SET SERVER VERSION
    public void SetServerGameVersion () {
        TNManager.SetChannelData("game version", 20161026);
    }


    //GET SERVER VERSION
    public void GetGameVersion()
    {
        checkVersion = TNManager.GetChannelData<int>("game version");
        print(checkVersion);
    }
}

7
TNet 3 Support / some problems with UI
« on: October 18, 2016, 12:16:21 PM »
Hi. I try create HP bar to unit, but again and again something wrong.

2 scripts on Player
create hp bar

   public static GameObject playerHPpanel;

   static UIHealthInfo _UIHealthInfo;


    // Use this for initialization
   void Start()
    {
       
        if (tno.isMine)
        {
            // not network sample
            //     GameObject slider = Instantiate<GameObject>(Resources.Load<GameObject>("HPpanelUI"));
            //     slider.transform.SetParent(GameObject.Find("MainCanvas").transform);
            //    _UIHealthInfo = slider.GetComponent<UIHealthInfo>();
            //     _UIHealthInfo.Target = this;
         
            // network sample
           Vector3 pos = new Vector3(37.0f, 4, 38);
           Quaternion rot = Quaternion.Euler(0, 45, 0);
           TNManager.Instantiate(2, "MenuCreate", "HPpanelUI", false, pos, rot);
           _UIHealthInfo.Target = this;

         }

    }

    [RCC]
    static GameObject MenuCreate(GameObject prefab, Vector3 pos, Quaternion rot)
    {

        // Instantiate the prefab
        playerHPpanel = prefab.Instantiate();
        // Set the position and rotation based on the passed values
        Transform t = playerHPpanel.transform;
        t.position = pos;
        t.rotation = rot;
       
         playerHPpanel.transform.SetParent(GameObject.Find("MainCanvas").transform);
        _UIHealthInfo = playerHPpanel.GetComponent<UIHealthInfo>();
       

        return playerHPpanel;
    }

Next script change position.
public class UIHealthInfo : MonoBehaviour {

   
    public HealthInfo Target { get; internal set; }
   
    // Use this for initialization
    UIHealthInfo _UIHealthInfo;

    void Start () {
   
   }

    void Update()

    {


        if (Target == null)
            return;
        Vector3 oldPos = new Vector3(Target.transform.position.x, Target.transform.position.y + Target.GetComponent<Collider>().bounds.size.y*3, Target.transform.position.z);
        Vector3 newPos = Camera.main.WorldToScreenPoint(oldPos);
        GetComponent<RectTransform>().position = newPos;


    }

}

its work in single, but in multiplayer something wrong, maybe problem with Target.

I try to go on easy way also, i off it all, and create Canvas into player unit. Its have problem too.
 Function DestroySelf - work and destroy unit, but after added Canvas with hp panel, DestroySelf 100% crush Unity or game.

8
TNet 3 Support / Re: Check players in trigger
« on: October 11, 2016, 03:53:06 AM »
Really thks!
 But i dont know what wrong whith my design. I orient on Warcraft3 - http://nightbeauty.ru/shop.jpg
Shop interface not active but you can see it. If you go to zone - shop switch to active.

9
TNet 3 Support / Re: Check players in trigger
« on: October 11, 2016, 02:14:37 AM »
its UI element.
player go to zone, interface shop set active. for all.... need for me.

void OnTriggerEnter(Collider col)


        if (col.gameObject.CompareTag("Player"))

        {
            ShopWallBase.SetActive(true);

        }

10
TNet 3 Support / Check players in trigger
« on: October 11, 2016, 01:20:19 AM »
Hi. I have shop in game, it open when Player whith Tag "Player" enter to zone.
 if (col.gameObject.CompareTag("Player"))
Shop open to all players not for one. What i need add to fix problem? Shop not have TNOobject. (players have, TNManager.Instantiate(2, "SoulCreate", prefabName, false, pos, rot);)

11
TNet 3 Support / Re: AutoSync
« on: September 22, 2016, 01:48:13 AM »
Ok. Thanks. I use it.
My C# knowlege is very low, sorr for my questions.

12
TNet 3 Support / AutoSync
« on: September 19, 2016, 02:13:00 PM »
Hi. My players have mouse click movement system.



  1. using UnityEngine;
  2. //using System.Collections;
  3. using TNet;
  4.  
  5.  
  6.  
  7.  
  8. public class Movement : TNBehaviour {
  9.     NavMeshAgent nav;
  10.    
  11.  
  12.     // Use this for initialization
  13.     void Start () {
  14.  
  15.        
  16.         nav = GetComponent<NavMeshAgent>();
  17.     }
  18.  
  19.  
  20.  
  21.  
  22.     // Update is called once per frame
  23.     void Update () {
  24.  
  25.         if (tno.isMine)
  26.         {
  27.             Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  28.             RaycastHit hit;
  29.         if (Physics.Raycast(ray, out hit, 50000)&& Input.GetMouseButtonDown(0))
  30.  
  31.         {
  32.             nav.SetDestination (hit.point);
  33.    
  34.         }
  35.         }
  36.     }
  37. }


Players movements have lags. I added AutoSync.
My question -
larger values "Updater per second" (>50 for example) its good or not? Or maybe have better way?

13
TNet 3 Support / Re: variables for ALL players
« on: September 13, 2016, 05:46:07 PM »
TNet comes packaged with an example scene. Load up this scene and see how everything works first.
I not search in TNet scene  how to use int, string, variables in multiplayer.

I read tutorials here http://www.tasharen.com/tnet/docs/
search "int" - nothing
search "variables" - nothing


RANDOM COPY-COPY-DELETE-DELETE-COPY-COPY FILES
and now its WORKS! i dont know what is problem, but now it realy work

i think in TNAutoJoin.cs i change public int channelID = 1; to public int channelID = 0;

14
TNet 3 Support / Re: variables for ALL players
« on: September 13, 2016, 04:08:18 PM »
Variables in unity its very easy to use. But in Tnet3 variables is a not easy to use for me.


  int playerSearchNumber = -1;
 tno.Send("SetMyVariable", Target.AllSaved, (playerSearchNumber + 40));

playerSearchNumber + 40???? What is it? my debag log show me -1, i fix to   tno.Send("SetMyVariable", Target.AllSaved, (playerSearchNumber += 40)); when debug show me 39 79... etc every time then i click but in 1 client not all. (1 client is  unity editor 2 client bilded game) i click, click, click in bilded game to much, then i click in unity editor, he show me 39 79... not more...

my Game have Players. Players click Start - Game started. Players have Numbers. Player1 have Number 1, Player 2 Number 2, etc.....

15
TNet 3 Support / Re: variables for ALL players
« on: September 13, 2016, 12:26:10 PM »
 Debug.Log("Value should be set to: " + value); not worked in RFC? - i dont see nothing

change all to:

    int playerSearchNumber;

    void OnClick ()
{
    tno.Send("SetMyVariable", Target.AllSaved, playerSearchNumber += 40);
    Debug.Log(playerSearchNumber);
}

    [RFC] protected void SetMyVariable (int value)
    {
        playerSearchNumber = value;
       
    }

Debug.Log show playerSearchNumber = 40 for 1 client, in other client  playerSearchNumber = 0

Pages: [1] 2