2 Player game on same device

Options
I have a game that will allow you to play 2 players locally or over the internet (TrueSync).

I am curious what would be a 'proper' way to instantiate 2nd player if game is played locally?

Comments

  • JeffersonHenrique
    Options
    Hi @Kreso,

    This could be a interesting feature for TrueSync, to simulate several players locally. Currently you have to do some workaround, to check if the game is locally or not.
  • devandart
    Options
    That's a feature, I also want to add to my game. :smile:
  • Kreso
    Kreso
    edited February 2017
    Options
    @JeffersonHenrique curious, how to differentiate between players?

    I guess these are 2 separate questions:

    1) How to differentiate 2 players while playing online?
    I tried reading owner.ID OnSyncedStart, but I get values such as 1 and 3, but sometimes 1 & 2... What works?

    2) How to create 2nd player in 'offline' mode / on same device? What would be best way to create another player in 'offline' mode so that inputs and physics work as expected?

  • JeffersonHenrique
    Options
    Hi @Kreso,

    1) You could compare "owner" with "localOwner" to make different statements, unfortunately the IDs are the same as the Photon Player, so they could be different from natural order 1,2,3...

    2) You need to do some workaround, for example, to know if the game is offline you can check "PhotonNetwork.connected", and so do some IF statement on OnSyncedInput.
  • Kreso
    Options
    @JeffersonHenrique gotcha, so in order to have 2 player GameObjects instantiated - how do I actually instantiate the 2nd player, since normally TrueSyncManager instantiates.

    Can I simply duplicate player GameObject via Instantiate?
    Since game is offline (there is no Rollback, SyncWindow etc...) should this work, or is there a more 'proper' way to do this?

    Thanks!
  • JeffersonHenrique
    Options
    @Kreso you could instantiate by SyncedInstantiate, doing this inside the IF statement so you could reuse your code in developments builds.
  • Kreso
    Options
    @JeffersonHenrique excellent! I completely missed there is a SynchedInstantiate. Thank you