Author Topic: DontDestroyOnLoad and TNManager.Create  (Read 2806 times)

Simie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
DontDestroyOnLoad and TNManager.Create
« on: June 18, 2014, 06:32:05 PM »
I have a few dynamic objects which persist between scenes. I am getting "Network ID ## is already in use" error messages, which appear to be caused by TNManager.LoadLevel resetting the object counter used for assigning ids. Is there a supported way of having network objects correctly surviving a scene load?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: DontDestroyOnLoad and TNManager.Create
« Reply #1 on: June 18, 2014, 08:39:39 PM »
You should not be setting TNet-created objects to be DontDestroyOnLoad.

If you want a static object that travels from scene to scene, then don't use TNManager.Create to instantiate it. Simply have it already be there with a TNObject attached and an ID already set.

Simie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: DontDestroyOnLoad and TNManager.Create
« Reply #2 on: June 19, 2014, 05:43:13 AM »
Alright, thanks.

MasterMoo

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: DontDestroyOnLoad and TNManager.Create
« Reply #3 on: July 25, 2014, 10:52:51 AM »
Hi Aren,

I have a follow up question.  I'm creating a turn-based strategy game.  In my first level the players select their combat units that they'll control.  Once all players have indicated they are ready the game loads the second level where the game play takes place.  I'm using TNet to instantiate the units in the first level.  Is there no way to persist those units to the game play level?  Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: DontDestroyOnLoad and TNManager.Create
« Reply #4 on: July 26, 2014, 04:04:21 AM »
Save the player selection in TNManager.playerDataNode (each player should save their own selection). When the level loads, each player is responsible for creating their units using the stored data.

I do this in Windward myself -- I save the player's zone ID, respawn position, pennant colors, ship colors, sails, inventory and ship selection in the player's data object. When the scene loads, I create the appropriate ship and "equip" items (attach scripts).