Author Topic: Assign TN Object ID on runtime  (Read 2216 times)

Eskinto

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Assign TN Object ID on runtime
« 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!

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Assign TN Object ID on runtime
« Reply #1 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Assign TN Object ID on runtime
« Reply #2 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.