Author Topic: How to share data across levels?  (Read 4994 times)

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
How to share data across levels?
« on: July 14, 2016, 04:29:34 PM »
If I have a player joining a setup screen and needing details on the current in-game state (drop-in coop), how do I call an RFC from the host in a level the new player isn't in yet? I've tried creating a universal GameManager object and class that doesn't get destroyed between levels (a GameObject with Don'tDestroyOnLoad and a static TNObject number) but that doesn't work.

Host > Load level "Intro", create server. Load level "Prepare", set up game. Load level "Level1", play.
Client > Load level "Intro", join server. Load level "Prepare", set up game. Needs info from host.

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
Re: How to share data across levels?
« Reply #1 on: July 14, 2016, 05:00:17 PM »
Hmm, maybe that works. RFCs aren't working, full stop.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to share data across levels?
« Reply #2 on: July 16, 2016, 12:51:54 AM »
You can be in several channels at once. One channel for the game, another for chat, a third one for settings if you want, etc.

TNManager.SetChannelData is the most robust way to associate permanent data with a specific channel that all players have access to as long as they are in that channel. No RFCs required.

TNManager.SetServerData is another option -- it's server-wide, so use it accordingly. Information about the entire world, list of player factions/guilds, etc would go there.