Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party Photon PUN 2 - Can a client spawn an object and send data to the others?

Discussion in 'Multiplayer' started by Paulx774, Jul 28, 2021.

  1. Paulx774

    Paulx774

    Joined:
    Mar 18, 2021
    Posts:
    103
    I'm trying to switch my singleplayer game to multiplayer. So, I already have built systems in my game and I'm trying to make the game multiplayer without changing them much.

    There's a driving scene in my game. In singleplayer mode, I spawn traffic cars beforehand and use them when it's needed (around ~25 traffic cars). In multiplayer, the game is like GTA. 1 driver and the others are shooters. The master client is not the driver. So, normal client should be able to send data about the traffic cars to the others.

    - In order to synchronize traffic cars, they must be created at runtime and they must have the PhotonView component, as far as I understand. Can a normal client send that spawning request to the others? If so, is sending 25 spawning request too much?
    - After spawning the traffic cars, AI will take control of the cars and AI will be driven from the client (the driver) in order to reduce the lag. Because, that's the one who's going to drive and should be smooth for the driver. Is this possible with Photon PUN 2?
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Yes, this is possible but for new projects, we would recommend using Fusion. It is tick based and handles even physical interactions in a smoother way.

    How many players would you like in one room?
     
  3. Paulx774

    Paulx774

    Joined:
    Mar 18, 2021
    Posts:
    103
    Minimum 2, up to 4 players.

    I'm already using Photon PUN 2. Do I need to rebuild the networking in my game? (Do I need to remove PUN 2 and add a new SDK). Also, I couldn't find any pricing data about Fusion.
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    It sounded as if your project was in the earlier stages. It only makes sense to switch to Fusion, when the project is fresh or if you can't reach the results you expect. The pricing will be comparable to PUN 2's but it's only announced in our discord (page not finished yet).

    About your case:
    You should be able to implement that scene with PUN 2, too. Yes, any player can instantiate objects and so any driving player will be able to control the AI cars (and send updates for them). If 25 is too much depends a lot on what else is going on. It should be fine but there are ways to optimize, if it's not. Let's bother with this, if needed.