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 - phil.atha

Pages: [1] 2
1
TNet 3 Support / Re: Objects Instantiate with No Owner
« on: November 09, 2017, 01:22:26 AM »
Figured it out.  So I was storing channel.id as a global variable in my TNEventReceiver-inherited class after I joined the channel, for convenience purposes I guess? This value was exposed and passed to my GameBuilder class on Awake. Evidently something was wrong with it however. Once I directly referenced TNManager.channel.id in the Instantiate calls directly they worked and created both player prefabs with the correct owners set.

But.. I haven't the slightest idea why this was the case. In my design the player can only ever connect to one channel at a time.  ???

On that note, it would be a little easier/cleaner if we could pass the Channel object as a variable into the Instantiate method rather than the ID int.

2
TNet 3 Support / Re: Objects Instantiate with No Owner
« on: November 07, 2017, 02:17:19 PM »
  1.     public class LoadingScreen : UIState
  2.     {
  3.         ..........
  4.  
  5.         [TNet.RFC]
  6.         public void CloseLoader()
  7.         {
  8.             StartCoroutine(Hold()); //All players are ready - Fade Out Screen Effect
  9.             GameBuilder.builder.SpawnPlayer();
  10.         }
  11.     }

So I have it called from the tail end of a loading screen. Not the best place, but it ensures it happens after I'm done loading the rest of the scene assets. I have all of my UI screens inherit from UIState, which is a custom GUI class that inherits from TNBehaviour. The reason for this is most of my UI overlays are required to be in sync across players.

The loading screen is displayed while the scene is changed from 'MainMenu' to 'Game.'
Just before we exit MainMenu we are sitting in the lobby waiting for players to be ready and the game to start.

I think the next thing for me to do is just sit down and strip everything out of the TNEventReceiver and see where I'm going wrong. All the example projects I've tried work properly, so its gotta be something I'm doing.

3
TNet 3 Support / Re: Objects Instantiate with No Owner
« on: November 06, 2017, 05:17:28 PM »
My class that calls scene building functions derives from TNBehavior like so:

  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5.  
  6. public class GameBuilder : TNet.TNBehaviour
  7. {
  8.         public void SpawnPlayer()
  9.         {
  10.             Debug.Log("Spawning Player");
  11.             FactionName f = TNet.TNManager.player.Get<FactionName>("PlayerFaction");
  12.             string apath = fDB.GetFactionPath(f);
  13.             TNet.TNManager.Instantiate(channelID, "GeneratePlayerCore", apath, true);
  14.         }
  15.  
  16.         [TNet.RCC]
  17.         public static GameObject GeneratePlayerCore(GameObject prefab)
  18.         {
  19.             Debug.Log("GeneratePlayerCore");
  20.             GameObject _mainCore = Instantiate(prefab) as GameObject;
  21.             Vector3 position = GetSpawnPoint();
  22.             _mainCore.transform.localPosition = position;
  23.             GamePlay.game.myCore = _mainCore;
  24.             Controller.instance.FocusMainCore();
  25.             return _mainCore;
  26.         }
  27. .....
  28. }
  29.  

If I change it to a Monobehavior, it doesn't appear to make any difference which is not at all surprising since TNBehaviour derives from Mono already. As of now, if I run this code on each client I get a player core instantiated BUT only locally, not remotely. But if I simply move both of those functions to my TNEventReceiver inherited subclass, they instantiate both locally and remotely.

4
TNet 3 Support / Re: Objects Instantiate with No Owner
« on: November 05, 2017, 01:42:36 AM »
I'm using the asset store version.

Edit: ARG!! I think I figured it out. All of the RCC events MUST be under the TNEventReceiver class unlike RFC's which apparently can be called from any TNBehavior.

@ArenMook is that correct? If so is that documented anywhere?

5
TNet 3 Support / Re: Objects Instantiate with No Owner
« on: November 04, 2017, 01:45:01 AM »
Anyone have any ideas? This is holding up progress.  :-\

6
TNet 3 Support / Re: Objects Instantiate with No Owner
« on: November 02, 2017, 03:50:10 PM »
That might be my issue. I've noticed that TNManager.players.Count becomes zero when changing scenes. So will I have to rejoin a channel for every scene change? That doesnt make much sense. Even more strange, I can see position and rotation updates on my client system (laptop) despite the player count resetting. It would be nice if there was more information in the TNManager about connected players and their state.

Test: I have a server and client connected via local LAN. Both systems show connectivity to the same channel, however the host system shows Players: 1, while the client system shows Players: 2. Why the discrepancy? It almost seems like the client still thinks its connected, but the host isnt.

Image 1
Image 2

Edit: Okay so I proved myself wrong. I stopped changing scenes and I found that my problem still exists. Might help to mention that the host can spawn objects properly on both host and client systems, but when the client spawns the object it only appears on his local system and, again, has no owner.

7
TNet 3 Support / Objects Instantiate with No Owner
« on: October 29, 2017, 10:54:08 PM »
I'm seeing this happen on player objects AFTER I've switched to my 'Game' scene. I'm keeping alive all of the objects that should carry over between scenes, and these objects that don't work (player home bases for an RTS game) do not have any other dependencies tied to them, just a simple dynamic TNObject.

Under what conditions might a TNO instantiate without an owner?

8
TNet 3 Support / Discord Chat
« on: October 25, 2017, 07:48:01 PM »
Querying for interest if anyone would find use in a Discord chat for TNET. I thought it might make sense to have another resource for discussion. The Forge community has one and I've found it useful for general questions.

9
TNet 3 Support / Best Practices: Checking For Player Readiness
« on: August 01, 2017, 11:07:32 PM »
I'd like to get some input from others as far as how they go about tracking user readiness when loading a game that requires global synced events. Currently my host and clients all change the level at the same time, then the host instantiates objects, but once the players are ready the game clock should start and the game begins.

I'm looking for techniques to tell when all the players are ready. So far I have a single IEnumerator on the host side that checks for a ready bool on all the clients, but other than tracking object types in the scene, what are some other creative ideas for checking player states?

10
TNet 3 Support / Re: RFC RCC Parms not getting passed
« on: July 18, 2017, 09:53:41 PM »
Thanks so much guys, removing the RFC seemed to be the specific thing that fixed it.

11
TNet 3 Support / Re: RFC RCC Parms not getting passed
« on: July 18, 2017, 10:24:58 AM »
Thanks Aren, I'll work towards that. In order to reduce overhead I'm having the clients each generate their own planets but I'm doing it with a common seed parameter so the result is exactly the same across all clients. I need to know when the Instantiate function completes so that it's ready/safe to send the parameter to the clients and kick off the process. Could I hook a delegate up to the RCC call?

12
TNet 3 Support / RFC RCC Parms not getting passed
« on: July 17, 2017, 01:10:45 AM »
Are there any known issues with parameters not getting pass or passed unreliably?

I'm passing a simple int to a function using tno.Send and it doesn't make it over to the function. Sometimes if I call SendQuickly it will work but its unreliable. I could be in an edge-case situation but I can't be sure. In doing my debug tracing I know the value is making it to my GeneratePlanet function just fine but from there it never makes it to the target  class and I can't figure out why. Anything glaringly obvious I'm doing wrong here?

Speaking of debugging, sometimes when attaching VS to Unity I sometimes experience issues with all the TNet functions firing. Does that happen to anyone else?

Code sample is as follows:
  1. class PFactory
  2. {
  3.         IEnumerator GenerateScene()
  4.         {
  5.             GUIManager.instance.SetState(GameState.Loader);
  6.             GameSettings _settings = ReadSettings();
  7.  
  8.             yield return new WaitForSeconds(2);
  9.  
  10.             //Some super secret code here ;p
  11.  
  12.             int perlinSeed = Random.Range(0, 90000);
  13.             TNet.TNManager.Instantiate(GameNetwork.instance.channel.id, "GeneratePlanet", path, true, perlinSeed);
  14.  
  15.             yield return new WaitForSeconds(2); //At least 1 seconds of loading screen
  16.             GameNetwork.instance.isLevelBuilt = true;
  17.         }
  18.  
  19.         [TNet.RCC]
  20.         static GameObject GeneratePlanet(GameObject prefab, int seedVal)
  21.         {
  22.             GameObject _planet = Instantiate(prefab) as GameObject;
  23.  
  24.             PBuilder pbr = _planet.GetComponent<PBuilder>();
  25.             //tns.tno.Send("Generate", TNet.Target.All, seedVal); //Never works
  26.                tns.tno.SendQuickly("Generate", TNet.Target.All, seedVal); //Barely works
  27.            
  28.             //Generate Vegetation
  29.            
  30.             //Cleanup
  31.  
  32.             return _planet;
  33.         }
  34. }
  35.  
  36. class PBuilder
  37. {
  38.         [TNet.RFC]
  39.         public void Generate(int seed)
  40.         {
  41.             perlinSeed = seed; //This value is always 0
  42.             //Magic Happens
  43.         }
  44. }
  45.  

13
TNet 3 Support / Re: Prefabs as Strings
« on: July 01, 2017, 01:25:09 AM »
Not only that but, how to I get the GameObject back to the method that called it so I can continue to work with it? In ExampleCreate.cs I see that ColoredObject returns a GameObject but that doesn't seem to be valuable since TNManger.Instantiate returns void. What am I missing?

14
TNet 3 Support / Prefabs as Strings
« on: July 01, 2017, 01:22:01 AM »
Q: What is the reason behind RFC prefabs being passed down as strings rather than object references?

I ask because this makes things somewhat difficult where I have a randomly selected environmental prop instantiate on my world. I have to have a big switch statement that keys off of the name to help find out which Prefab subfolder the object is located in. Not the worst thing in the world but it's forcing me into messy code.

15
TNet 3 Support / Re: RFC Calls in Other Classes
« on: June 14, 2017, 01:42:31 PM »
Understood, thanks.
I guess it's a design dilemma. I thought that maybe having a network-synced clock was the 'proper' way to do things, because it would guarantee the clock time is the same for all clients. On the other hand I don't see how that's possible without flooding messages to each client for every clock tick.

Pages: [1] 2