Author Topic: Give characters to other player  (Read 3648 times)

sloopernine

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 47
    • View Profile
Give characters to other player
« on: August 18, 2013, 07:03:03 AM »
Hi

Lets say I am making a RTS game, And there are for example 4 players playing. Suddenly someone give upp and lefts game.

Are there anything in TNet that makes it possible to give another player the ownership of created TN objects ?

And I know there are recommendations that host player have all AI handling, but I wanted to try to make each player have control over their own AI characters in order to ease up on hosts up bandwidth.

Any suggestions ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Give characters to other player
« Reply #1 on: August 18, 2013, 07:51:15 AM »
Ownership gets transferred automatically, however you can also do it manually via tno.SetOwner.

MLow

  • Guest
Re: Give characters to other player
« Reply #2 on: August 20, 2013, 08:46:11 PM »
If I start a server in a unity build(not the executable server). Then the server disconnects, TNet transfers the server to a client? That's not at all what I want in my situation, where I have control over the server. Maybe I'm a bit confused.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Give characters to other player
« Reply #3 on: August 21, 2013, 09:48:54 AM »
If the actual server disconnects (that is, TNServerInstance or stand-alone executable), everyone connected to that server will get disconnected.

If the host disconnects (who is just another player), the ownership will be transferred to another player.

sloopernine

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 47
    • View Profile
Re: Give characters to other player
« Reply #4 on: August 27, 2013, 05:39:23 PM »
Are there any "flags"/"tags" that can be set for each created object by the host. That tells if the gameobject are going to be transfered to next host or deleted.

For example the host got his player character, and also handle the NCP players. Host leaves, his character would need to go as the new host already have his character, but the NPCs would be nice to transfer as they still live their lives...

If not this would be nice to add into TNet with some bool statement when creating objects

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Give characters to other player
« Reply #5 on: August 28, 2013, 11:30:33 PM »
It's all in the flags you use when creating objects. If you specify "true" for the "persistent" flag, then the object will remain after the player leaves. If "false", the object will be automatically deleted when the player leaves. Make sure to create your avatars with "false".

sloopernine

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 47
    • View Profile
Re: Give characters to other player
« Reply #6 on: August 29, 2013, 01:58:10 AM »
Thanks, this really makes some interesting features appearing in my head.

I was thinking, if lets say you play a game with alot of NPCs. Maybe it would be better to split the NPC handling between every player instead of just letting host do it, that would ease up on hosts up bandwidth. And also if players are in different areas of the game, that host dont need to take info on what is happening far away. It is like the non host player are playing his own little game

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Give characters to other player
« Reply #7 on: August 29, 2013, 03:29:57 PM »
Yup, and you can also change the ownership of objects if you need, so say a player that goes far away can "take over" the ownership of nearby NPCs, thus completely removing the need for the host to do any kind of logic (since they are so far away).