Sync data without whole scene loading

Options
Hello !

Let's say I'm working on a PC 3d racing game and I want to show Speedometer / RPM on a mobile device's screen connected to the game. I don't want to sync whole scene, just to send/receive few float values. How is it possible to be done? Thanks !

Best Answer

Answers

  • Thanks, Christian, just one more question... On PC side I have 3d objects with Photon View assigned. They're automatically trying to appear on the mobile version. Since there are no same 3d scene in mobile version - they're trying to appear in any current active scene. What I'm doing is that immediately deleting any "new objects" inside "Update" function on mobile side. Is there any better solution for this?
  • This is tricky, but should be possible. I guess in this case you should use manual instantiation. What you basically do is to call a RPC (you can also use RaiseEvent since you may don't have a PhotonView component to use before instantiating your 3D object) and execute it only on the PC clients. If you use RaiseEvent(...) function you can set RaiseEventOptions. Within these options you can specify TargetActors and define, who receives this raised event. This however gets a bit complex when you allow other players to join later. So the easy way might be, to raise this event for everyone and add some kind of 'decider' to your OnRaiseEvent(...) callback. Something like:
    
    if (eventcode == yourEventCode)
    {
        if (isPcClient)
        {
            // Instantiate
        }
        else if (isMobileClient)
        {
            // Do nothing
        }
    }
    
    If you allow other clients to join the game later on, you should buffer the instantiation as PhotonNetwork.Instantiate(...) does. You can also find this in the RaiseEventOptions. It is called CachingOption.
  • minpu
    Options
    @Christian_Simon: I have a similar purpose that to send and receive data. But RaiseEvent and OnEvent hanlder in different scenes, currently it does not work. So could you make a simple project to show me how to do, please?
  • What exactly isn't working? Do you have any error or warning logs in the console?

    Did you register OnEvent handler with something like PhotonNetwork.OnEventCall += OnEvent;?