Author Topic: logic GameManager through network  (Read 8715 times)

Elmo loves cookies

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
logic GameManager through network
« on: December 13, 2017, 12:05:59 AM »
I try to make lobby - there clients connect and waiting for start by host,
every client instancing with his TNobject in UI panel(and RFC work as well there, because TNObject creating and generate ID after joined in channel),

but problem send RFC command from GameManager(host), because if I add TNObject to GameManager with some channelID(like = 1), then try send from this to others in tha same channel(example: tno.Send("LoadLevel", Target.Others)) - its dont work :(

How can I use TNObject in manager class for sending RFC commands?


cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: logic GameManager through network
« Reply #1 on: December 13, 2017, 03:09:08 AM »
Use TNManager.LoadLevel, it'll load the level for all network clients.
TNManager.LoadScene isn't networked.

edit: TNManager.LoadLevel needs to be called by the host

Elmo loves cookies

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
Re: logic GameManager through network
« Reply #2 on: December 13, 2017, 03:31:34 AM »
Yep, TNManager.LoadLevel - work is fine, but I try to send RFC - and its dont work for me, how its is possible to have only one Canvas in start scene(with GameManager class for manipulation all states of the game and sync network values - like: time, mode etc before start GameLevel)?

then players connect to lobby - they dont load new scene - they are stay in the first scene - and there need some network sync(sync work between created UI prefab with TNObject[with dynamically ID]): how there host with TNObject on gameManager class can send RFC to others?

by the way - if I load GameLevel by TNManager.JoinChannel - where LevelManager have TNobject - there RFC work is perfect. - just its is imposible send in the first scene on GameManager with static ID:(
there TNObject on GameManager on Start scene(before I connect to server and some channel)
« Last Edit: December 14, 2017, 11:58:56 PM by Elmo »

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: logic GameManager through network
« Reply #3 on: December 13, 2017, 03:53:16 AM »
You can't network objects without being connected to a network :P you have to join the server and a channel first. After that you can instantiate your networked objects and send RFCs with them. Static TNObject's aren't recommended anymore because of the multi-channel stuff.

To clarify: you can't (shouldn't?) network objects post-connection. They shouldn't exist until you've joined a server and channel.
This thread may be relevant: http://www.tasharen.com/forum/index.php?topic=15449.0

Elmo loves cookies

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
Re: logic GameManager through network
« Reply #4 on: December 13, 2017, 04:18:02 AM »
oh, Thanks so much!!! TNObject work only after TNManager.JoinChannel and TNManager.Instantiate.
« Last Edit: December 13, 2017, 07:24:40 AM by Elmo »

Elmo loves cookies

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
Re: logic GameManager through network
« Reply #5 on: December 13, 2017, 08:54:09 PM »
ohh No, I still have this problem, I don't understand - How send RFC from GameManager(canvas UI - starter object) to other players? I added TNObject with specific ID on Canvas UI(starter GameManager which I load on start game(before connect)) -> connect to some server -> connect to some channel = and can't send RFC to other player in this channel from TNObject (which I came with) - thats should not work?
« Last Edit: January 13, 2021, 03:09:59 AM by DioAlias »

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: logic GameManager through network
« Reply #6 on: December 14, 2017, 06:22:40 AM »
I'm having a hard time understanding you. Make whatever networked object you're trying to use a prefab with a TNObject (id of 0) and use TNManager.Instantiate when you join a channel. Everything will work then. I don't know what use case you're trying to make work, so that's the best, most generic advice I can give.

Also, you could refer to the tutorials and the example scenes packaged with the TNet asset to see how certain practical tasks are accomplished.

Elmo loves cookies

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
Re: logic GameManager through network
« Reply #7 on: December 14, 2017, 10:54:33 AM »
Just example of photon network logic:

GameManager+tno(photonView) - thats manager class - we can send RFC when we connect in the channel,
on TNet - when I connect to channel - I can't send RFC from tno attached to GameManager since start the game(because it is not created by TNManager.Instantiate or TNManager.JoinChannel)


Well: I try to make - all player connect in lobby(one channel), and Host can send there RFC(setUp additional game options) - and after that send for everyBody start the Round.
 - but I can't send because GameManager don't have tno for this(because GameManager is class from start the game - where we were offline(before connect))
« Last Edit: December 14, 2017, 11:02:18 AM by Elmo »

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: logic GameManager through network
« Reply #8 on: December 14, 2017, 05:30:22 PM »
right after joining a channel, look into this:

  1. your_TNBehaviour_script.tno.TransferToChannel(channelID);

I use this method to manually create TNO's...

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: logic GameManager through network
« Reply #9 on: December 15, 2017, 08:00:26 AM »
I'd have GameManager inherit TNEventReceiver then override the OnJoinChannel function. In that, I'd check if we're at the lobby portion of the game and instantiate (via TNManager.Instantiate) a LobbyManager if it doesn't exist. This LobbyManager has the TNObject component with id of 0 and handles all lobby-related RFCs while in the lobby portion of the game.

Elmo loves cookies

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
Re: logic GameManager through network
« Reply #10 on: December 16, 2017, 01:55:07 AM »
yep, that best logic with tno on LobbyManage, thanks so much!!! I thought what it is possible to have tno on GameManager(with inherit TNEventReceiver)