Author Topic: Proximity based updates?  (Read 401 times)

Vancete

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Proximity based updates?
« on: August 02, 2017, 06:07:03 AM »
Hello,

I'm trying to pick a good networking system to do a community game.

The server should support up to 50-100 players in a single scene. Is there any easy way to make TNET working in a 'proximity based updates' way?

Thanks!

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 143
  • Posts: 268
  • TNet Alchemist
    • View Profile
Re: Proximity based updates?
« Reply #1 on: August 02, 2017, 03:38:22 PM »
TNet uses a "channel" system that can be used (and seems to be designed for) your needs. You split your scene into however many regions you feel is necessary, and then as your player travels around the scene they join / leave channels according to the region they're in. Not only does this effectively result in proximity-based network updates, it also completely cleans up objects from channels that you leave. Objects belong to channels, so when you're no longer in that channel the object gets destroyed, and when you join a new channel all objects belonging to that channel are automatically created for you. This reduces GPU load as you won't have to be rendering any distant complex objects at any LOD if they're outside your region, and it also reduces CPU load as there won't be any MonoBehaviour's executing outside your region.

Reference (straight from the horse's mouth, so to speak): http://www.tasharen.com/forum/index.php?topic=15211.msg66256#msg66256

Though I should add: splitting your scene into these regions - and joining/leaving channels based on which region you're in - isn't built directly into TNet. Because there can be a million different types of scenes (flat, spherical planets, something more abstract, etc) it'd be impossible to handle automagically, so you'll have to figure out how to split up your scene, how to determine which region a player lies in at any time, and then join/leave the appropriate channels.

Vancete

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Proximity based updates?
« Reply #2 on: August 03, 2017, 01:37:54 AM »
That can be a solution, but is has a problem:

If two players are in two different channels, but close to the limit (one on the right side of channel 1, the other on the left side of the channel 2), they will be near, but won't see the each other. What about this?

Thanks!  ;)

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 143
  • Posts: 268
  • TNet Alchemist
    • View Profile
Re: Proximity based updates?
« Reply #3 on: August 03, 2017, 02:21:05 AM »
Simply join both channels 1 and 2. You can be part of more than one channel, so it might be a good idea to overlap the regions a bit, or just lay them out in a grid and join the surrounding cells. Depends on your setup.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,137
  • Toronto, Canada
    • View Profile
Re: Proximity based updates?
« Reply #4 on: August 03, 2017, 04:39:05 AM »
Multiple channel support is a wonderful thing. ;)

Vancete

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Proximity based updates?
« Reply #5 on: August 03, 2017, 04:49:04 AM »
So the thing is to do lot of little channels and then join your channel and the 5 surrounding you? That makes sense.

Another thing, what about if I want a global chat separated from the system mentioned above?

Many thanks, I really appreciate the support.

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 143
  • Posts: 268
  • TNet Alchemist
    • View Profile
Re: Proximity based updates?
« Reply #6 on: August 03, 2017, 05:05:58 AM »
Exactly.

You'd just join a "Global" channel upon connecting to the server, and never leave it.