[SOLVED] Can I use two cameras?

Options
I want player 1 to use camera 1 and player 2 to use camera 2. It doesn't seem to work. I think the sync function updates so both clients use the same camera. If I put code in a void Start() then they both use camera 1. If I put them both in public override void OnSyncedStart() they both use camera 2. I am working on a game similar to Clash Royal so I will also take other suggestions on how to fix it so the local player is always on same side of the screen.

if (owner.Id == 1) { cam1.enabled = true; cam2.enabled = false; } else { cam1.enabled = false; cam2.enabled = true; }

Comments

  • JeffersonHenrique
    Options
    Hi @Kobaltic,

    I think you are facing this problem because you are using "owner" and not "localOwner", so this piece of code is executed twice in each machine and in the same order ( "else" part is the last then you get cam 2 enabled always ). To fix you need to use "localOwner" and it will be better if you create another TrueSyncBehaviour (that belongs to none) just to do that, you attach this script to TrueSyncManager so it will don't have an owner.
  • Kobaltic
    Options
    Thank you @JeffersonHenrique. That worked.
  • Mehdi22
    Options
    Does the first player ID always equals to 1?