Search Unity

Multiplayer AI traffic

Discussion in 'Multiplayer' started by SamohtVII, Aug 3, 2021.

  1. SamohtVII

    SamohtVII

    Joined:
    Jun 30, 2014
    Posts:
    370
    I am using a traffic system that spawns when the player spawns. It is a multiplayer game (PUN2) but the traffic will not be in sync when 2 different players spawn at different times. It will also fall out of sync on collisions that are not exactly the same which will become impossible due to smallest bits of lag.

    Can anyone suggest a way to keep traffic in sync. I'm thinking of syncing every car every one second with the hosts traffic cars but given a large number of cars will this just make my (mobile) game lag heaps? THe issue I also have is to have the car after being placed is to be moving at is previous speed. Instead it gets re-placed then starts from 0mph and builds back up speed.

    Thanks
     
    Last edited: Aug 3, 2021
  2. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    Maby Photon is not a good idea.
    It only allows you 500msg/second on every room. Your problem will probably be that the cars are sending more than 500msg every second.
    It seams that you are using a lot of cars.
    Try with other solution like Mirror or Toms networking solution
     
  3. SamohtVII

    SamohtVII

    Joined:
    Jun 30, 2014
    Posts:
    370
    Hmmm unfortunately it's too late to change. I'm deep into Photon with a lot of work already done. I highly doubt I will have over 500 or even 100 cars roaming around if that changes anything.
    Sounds like when I said Large number of cars causing it to lag i was under valuing how much PUN and mobiles can handle
    Thanks
     
  4. qbvbsite

    qbvbsite

    Joined:
    Feb 19, 2013
    Posts:
    83
    I agree with @r31o maybe PUN2 isn't the networking solution you need. For my project I used a network library and created my own server. You can check out my blog here for details: https://forum.unity.com/threads/creating-an-isometric-2d-rpg-mmo-ongoing-series.998851/
    Its still a work in progress but had many of the same issues you had.
     
    Joe-Censored likes this.