Author Topic: instantiation problem.  (Read 3826 times)

tstack

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 12
    • View Profile
instantiation problem.
« on: May 25, 2016, 02:08:49 PM »

Clearly my problem, not TNet's   :)

Here is my question: I have a non-network product that wants to instantiate the player.

Is it possible to add a player to the network that is already instantiated? Or does TNet Manager absolutely have to do the instantiation?

It is possible to have another script instantiate the player, then have TNet add the existing player to the clients?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: instantiation problem.
« Reply #1 on: May 26, 2016, 01:01:06 PM »
Due to the way TNObject life cycle works, it must be either instantiated or exist when you load the scene. You can't add it randomly.

I suggest simply separating your logic a bit. For example in Windward, I had a GamePlayer class that would be instantiated as soon as the player joins the channel, and this GamePlayer class would then be used for certain forms of communication and nothing else. When it was time for players to control some ship, they would simply send an RFC on their GamePlayer object saying "I am not going to be controlling ship XYZ". This made it possible for players to "posess" NPCs as well -- a very handy feature.