Author Topic: How can i "not" load a level after a channel connect  (Read 1790 times)

bariscigal

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 15
    • View Profile
How can i "not" load a level after a channel connect
« on: August 07, 2014, 04:47:45 AM »
Hi
This can be something i am missing in the documents. But i couldn't find a way to control the scene load time. When a succesfull channel connect Tnet automatically loads the scene with the channel name. How can i stop this happening and load with an rfc call or a yield ed time?
 I am trying to synchronize my closed 1vs1 game loading.
Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How can i "not" load a level after a channel connect
« Reply #1 on: August 08, 2014, 06:48:07 AM »
Pass a 'null' for the scene name when joining a channel.

Just note that loading a scene via an RFC is a bad idea. TNet manages lifetime of object creation and RFCs in a specific order, and newly joined players receive packets in a specific order. Loading the scene is always first, followed by creation calls, followed by RFCs.

If you make scenes load from RFCs, you effectively break this order as loading the scene won't be first anymore. Objects may not be in the correct state, and RFCs will be fired before your scene loads, likely causing issues.

It's a much better idea to pass 'null' when joining a channel if you know that all the objects in the scene are already present and none will be dynamically created, allowing you to use chat and such. When it's time to actually play the game though, TNManager.LoadLevel the proper game scene.