Author Topic: Multiple TNObject Components  (Read 2037 times)

Falyn

  • Guest
Multiple TNObject Components
« on: March 08, 2013, 11:19:50 PM »
I'm currently in the process of converting my project from the built in Networking to TNet. So far the transition has been very smooth. I'm currently facing an issue when trying to Create a prefab with multiple TNObject components in its hierarchy.

I currently have a structure like

-Player
    -Inventory
    -Equipment

Where I would like to have each object with its own TNObject. The inventory and equipment both derive from an ItemContainer base class which is handling the synchronization. Calls like NetworkMoveItem, NetworkAddItem, NetworkRemoveItem etc.

With the built in networking I was able to Instantiate my player, then allocate 2 extra NetworkViewID's and send those over via RPC. This would allow the Inventory and Equipment to link up over the network with their counterparts on other clients.

Now my question is is there anything similar to Network.AllocateViewID(), after looking a bit through the Create code it seems the TNObject unique ids are a decrementing counter kept by the current channel.

Alternatively I could Create the player, then call Create for the extra children that are needed, but I was just wondering if there is a way to keep my current implementation.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Multiple TNObject Components
« Reply #1 on: March 09, 2013, 02:51:37 AM »
The more TNObjects / NetworkViews you have, the slower each lookup becomes. I suggest you reconsider the need to allocate IDs to begin with. Have a manager script (on your player) through which you will communicate. And if that's too much redesign -- that's fine too. You can just have child TNObjects. You're not limited to just one per prefab after all.