Send variable from client to another one

Hi, is there any possible way how to simply send int from one client to another? I have already searched for it on both PUN and Truesync forum and I didn't find anything except:

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){ print("working"); stream.SendNext(randomInt); }
...unfortunately this script didn't even print "working", but if it is the way how to properly send int, then I will try to somehow fix it.

It's because I have a game where the player build a castle and then fight with it (in separate scene) against another player. And I need just before fight start players to receive save of castle from each other, like which blocks and where are put on castle.

So, if you think Serialize view is a good decision, or if I should go by different way, please left a comment :)

Best Answer

Answers

  • Hi @Vokyczech, are you working with TrueSync? or are you just using PUN?
  • Thanks for reply @JeffersonHenrique, I am using TrueSync.
  • Hi @Vokyczech, to send inputs across clients you can use TrueSyncInput, take a look at some of our demos to check how it is done.
  • Hi @JeffersonHenrique, so you are telling me that if I want at the game start send between 2 players like 50 integers, which have nothing to do with some kind of movement, the best solution is send it trough a TrueSyncInput? (for every saved block at castle is information of type, position and rotation, so if there are like 16 blocks, it will sum into something near 50 integers what have to be send to the other player).
    I really appreciate your help, especially when my english skills aren't any good. :)
  • @JeffersonHenrique thx a lot..
    By the way, you are doing great job on TrueSync, guys .:)
  • Hey @JeffersonHenrique ,
    I have been following this thread because it's something I am interested as well, for my game.

    I have a scene where players can add obstacles before the level starts.
    I was under the impression that I can use PUN, and RPC's.
    https://doc.photonengine.com/en-us/pun/current/manuals-and-demos/rpcsandraiseevent
    Then, once all players have needed values, I can start the game (and TrueSync).

    Please let me know if I should not do this for some reason.

    Thanks!
    Kreso
  • Hi @Kreso, you can enable the TrueSyncManager after you have set your environment, you just need to take care if the scenario will be exatcly the same in all objects related to TrueSync, basically you can be sure of this if checksum is OK in the first block (200) of ticks.
Sign In or Register to comment.