Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: Eskinto on March 31, 2015, 08:50:49 AM

Title: Assign TN Object ID on runtime
Post by: Eskinto on March 31, 2015, 08:50:49 AM
Hello! thanks for an amazing plugin, it's made moving from single-player to multiplayer extremely easy :)

I'm using PoolManager (a prefab-recycling plugin) to pool/recycle prefabs instead of using instantiate/destroy, the game needs this because we spawn/despawn a lot of prefabs on runtime

The problem I'm having is that when the level loads and the prefabs get instantiated, their TNObjects don't have a unique ID, and this throws an error

My workaround so far has been:

Modifying the TNObject script to do a "UniqueCheck()" on Awake(), removing the If Editor checks and so on...

I'm not sure what's the best way to do this, since it's going to run on all the clients and it might give inconsistent results eventually, any ideas?

thanks!
Title: Re: Assign TN Object ID on runtime
Post by: voncarp on March 31, 2015, 12:45:23 PM
I have my own custom pool manager.  If your not creating the prefabs then they won't need a TNObject nor unique ID.  The pool manager itself will need a TNObject.  And then you send RFC calls as necessary to adjust the position, rotation, direction, enable, etc to the pool manager to sync the objects across the network.

If they don't have a uniqued ID and need one assign them a unique ID in the beginning.  Pick a range to assign them.
Title: Re: Assign TN Object ID on runtime
Post by: ArenMook on April 01, 2015, 11:45:21 PM
You should be creating objects using TNManager.Create, not instantiating them directly. TNManager.Create will make the instantiated object's IDs unique.