Author Topic: Instantiating objects on LevelLoad  (Read 2260 times)

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Instantiating objects on LevelLoad
« on: January 14, 2015, 08:53:16 AM »
When a client joins all the objects are instantiated that were created in the game he is joining.

Where do I need to look if I don't want that?

If the objects have rigidbodies and I have several streaming maps.  By the time a player gets over to a different section of the map the rigidbody has already fallen out of range.  This leads to one character able to see and grab the object and the other player can't.

Where are these objects saved so I can grab them and stop them from falling?  Can I stop TNManager from creating objects on the client until I request it to?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Instantiating objects on LevelLoad
« Reply #1 on: January 14, 2015, 10:20:25 PM »
All objects get created before OnNetworkJoinChannel gets called. If you want to prevent some logic from running during load, check TNManager.isJoiningChannel

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Instantiating objects on LevelLoad
« Reply #2 on: January 18, 2015, 02:30:17 AM »
All objects get created before OnNetworkJoinChannel gets called. If you want to prevent some logic from running during load, check TNManager.isJoiningChannel

I suspect they are coming from the RPCs called from the ongoing game?  Are they stored in an array?

Sorry, I'm kinda stuck and not sure how to proceed.

I might just have to grab all the items individually once I join a channel, although that seems a bit heavy.  There seems like their should be an easier way.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Instantiating objects on LevelLoad
« Reply #3 on: January 18, 2015, 04:37:05 AM »
Yes, all RFCs and RCCs are stored on the server in the same order they were originally sent out. Once all RCCs and RFCs arrive, TNManager.isJoiningChannel will be set to 'false' and OnNetworkJoinChannel will be sent out. Note that Start() and Update() functions can and will execute in between of packet arrival and OnNetworkJoinChannel, because packets can and will arrive spread out across several frames.

This is why it's important to check TNManager.isJoiningChannel or waiting for OnNetworkJoinChannel() before sending out anything and/or doing any game-specific logic such as creating player avatars.