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

Pages: [1]
1
TNet 3 Support / Re: Assigning names to RFC ids
« on: February 24, 2017, 01:15:40 PM »
Thanks for all this.  I was experimenting with RFC IDs to see if it affected a very strange problem I am having.

I am trying to sync some GameObjects but when connected to a server their Y position is off by about -745,000 units!  This is happening on the host when connected to a standalone server and is extremely hard to nail down as it is not always present.

If I comment out part of my SetPos RFC (the transform.position = ??? part) which is not even executed on the host the problem goes away.  If I uncomment it again the problem will stay gone away until randomly returning and staying.  Even after rebooting (C&S concurrently) and clearing everything it is still present.  Very annoying and time consuming!  I have been doing Unity for 4 months, after more than 20 years of C++ app and game coding nothing prepared me for how fiddly Unity can be sometimes!  I found UE4 C++ a lot easier.

I would love to post about this much bigger problem but I can't pin it down and am not even sure it is directly related to TNet as here is lots more going on.

Anyway I am working away on trying to work this out.  The RFC numbering did not affect this problem but this is how I got here early on.



2
TNet 3 Support / Re: Assigning names to RFC ids
« on: February 24, 2017, 03:27:11 AM »
I worked out that the null error is due to using 0 as an ID (silly me) but am still curious if the numbers are shared across all GameObject types.

3
TNet 3 Support / Re: Assigning names to RFC ids
« on: February 24, 2017, 03:22:30 AM »
I forgot to ask.

Are these numbers unique to this GameObject type or is it a shared project-wide pool?  Obviously if the first is true then I don't have a problem.

4
TNet 3 Support / Assigning names to RFC ids
« on: February 24, 2017, 03:09:17 AM »
Hello TNetters,

I have been trying to assign names using enums a struct or a class to RFC numbers but have not been able to get this working.

The code below shows a couple of the methods I tried.  They compile but produce an error during play for each GameObject using them:
ArgumentNullException: Argument cannot be null.
Parameter name: key

 
  1.     public enum RFCNumbers
  2.     {
  3.         DoSomething = 0,
  4.         DoSomethingElse = 1
  5.     }
  6.  

  1.     public static class RFCNumbers
  2.     {
  3.         public const byte DoSomething = 0;
  4.         public const byte DoSomethingElse = 1;
  5.     }
  6.  

  1. tno.SendQuickly((byte)RFCNumbers.DoSomething, Target.OthersSaved, theThingToDo);
  2.  

5
TNet 3 Support / Re: Static TNObject IDs
« on: February 22, 2017, 01:17:58 PM »
I said I would post when I got the code working to generate static tno IDs for all map objects.  This version seems to suit my needs.

  1. using UnityEngine;
  2. using UnityEditor;
  3. using TNet;
  4.  
  5. public class EditorTNIDAssigner
  6. {
  7.     [MenuItem("TNet/Assign IDs")]
  8.     static void AssignIDs()
  9.     {
  10.         int counter = 0;
  11.         Debug.Log("[TNet ID Assigner] iterating selected objects...");
  12.  
  13.         GameObject[] gameObjects = GameObject.FindObjectsOfType<GameObject>();
  14.         foreach (GameObject go in gameObjects)
  15.         {
  16.             TNObject tno = go.GetComponent<TNObject>();
  17.  
  18.             if (tno == null)
  19.                 continue;
  20.  
  21.             if (tno.parent != null)
  22.                 continue;
  23.  
  24.             SerializedObject sObject = new SerializedObject(tno);
  25.             SerializedProperty spropID = sObject.FindProperty("mStaticID");
  26.             if (spropID == null)
  27.             {
  28.                 Debug.LogError("Could not find 'id' property on " + tno.gameObject.name);
  29.                 continue;
  30.             }
  31.             spropID.intValue = ++counter;
  32.             sObject.ApplyModifiedProperties();
  33.         }
  34.         Debug.Log("[TNet ID Assigner] Done! Assigned " + counter.ToString() + " ids");
  35.     }
  36. }

6
TNet 3 Support / Re: Static TNObject IDs
« on: February 22, 2017, 11:49:32 AM »
Hello cmifwdll, thank you for the useful code snippet, I have already adjusted it for all objects but for some reason it cannot find the "id" property, I will look into it further and post the script back here when it is working.

And hello ArenMook, I can see you are busy on here answering almost every question which is great.  The forum thing is a little restrictive as I can't post either your code or ours publicly including screenshots but I generally have no problems using it as long as I don't give too many examples.

I am working on 2 titles, the first game is much smaller and could be ready this year, it is aimed at mobile and is primarily a single player game but with support for MP coop.  There will be lots of NPCs (notably farm animals) which are directly of the gameplay as well as a loads of power ups (mostly coins).  I have a small test map with 78 placed objects and have barely started but there will be plenty of optimisation and net culling to come, it really depends on how TNet performs.

Interestingly the placed power ups could be placed with a spawner script as they may respawn so I could manage here.  The other characters and triggers/switches would need to have IDs entered unless I just instantiate everything on Awake which is longwinded.  It is especially difficult as normally have to click each object and then scroll down part lots of components to see TNObject at the bottom.

I understand that these IDs need to be set at design time as they need to match up and can see potential pitfalls if they were automatic as the same ID could be reassigned after deletion.  On the other hand I find it strange that I am having to type them in when I just expect there to be an automatic option (perhaps I am being unreasonable here).  I duplicate objects all the time too which makes it especially tricky.

The second game is Steam/Desktop/Console targeted and is much bigger.  It can only be described as a combat adventure with interactive vehicles and maps from 1 to 4KM across.  This supports single player and MP modes.

TNet's save feature is amazing, also the general the API is very well made.  I have already created a generic "NetSyncTransform" class with 4 range sliders and basic prediction that I can attach to any dynamic game object (with automatic RB detection if one is present).  As most of the objects don't move much (power ups/animals/non woken enemies) TNet looks just the ticket.  However I really could not possibly manually manage all those IDs so that editor script will sure come in handy but I will be looking carefully to see if I can somehow modify the TNObject class to auto-assign on placement.







7
TNet 3 Support / Static TNObject IDs
« on: February 19, 2017, 03:45:42 AM »
I am new so please appreciate that I am still learning TNet and probably post in the wrong places.  As I am not allowed email the author/seller that I just paid my money to I am posting here for the World to see.

After spending a few days slowly integrating TNet into my game  I have struggled past a number of things including player spawning, and enabling "NoDelay" but the latest and most troublesome is with TNObject IDs for placed objects.

In short, specifying an ID in the editor manually (even with the value slider/warning icon) is not an option.  There are simply too may placed objects scattered over large areas to manage.

I have tried to make a "normalise" editor script to assign IDs and even modify the custom inspector code for TNObject (which could potentially auto assign onPlaced) but the changes are not applied because of "serialization" issues and probably because my objects are prefabs.

Searches indicate that an earlier version of TNet had such a script.

Pages: [1]