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

After cutscene the multiple players camera not properly working

Discussion in 'Multiplayer' started by sokratos195, Apr 6, 2021.

  1. sokratos195

    sokratos195

    Joined:
    Jan 23, 2021
    Posts:
    2
    What happens is the cameras does get re-enabled when i call stopcutscene but only the last camera which is the P3 Cam is only live all others are standby so all players see P3 perspective.

    EDIT: I solved it by using another method of activating and deactivating the cameras, by attaching a script to the camera directly and deactivating and another script attached to player to reactivate instead of directly activating/disabling virtual camera component, this method deactivated the game object of the camera itself. so maybe that's why it works because i didn't play with virtual camera component this time. Unnecessarily complicated but this is the workaround I found with my limited skills.

    Code (CSharp):
    1. public void OnTriggerEnter2D(Collider2D collision)
    2.     {
    3.         if (collision.tag == "P1" && isCutsceneOn == true)
    4.         {
    5.             anim.SetBool("cutscene1", true);
    6.             GameObject.FindGameObjectWithTag("P1Cam").GetComponent<Cinemachine.CinemachineVirtualCamera>().enabled = false;
    7.             GameObject.FindGameObjectWithTag("P2Cam").GetComponent<Cinemachine.CinemachineVirtualCamera>().enabled = false;
    8.             GameObject.FindGameObjectWithTag("P3Cam").GetComponent<Cinemachine.CinemachineVirtualCamera>().enabled = false;
    9.             anim.Play("OpeningScene");
    10.             GetComponent<EdgeCollider2D>().enabled = true;
    11.             Debug.Log("Cutscene1");
    12.             Invoke(nameof(StopCutscene), 17.2f);
    13.         }
    14.     }
    15.     void StopCutscene()
    16.     {
    17.         if(photonView.IsMine)
    18.         {
    19.             Debug.Log("enabled");
    20.             GameObject.FindGameObjectWithTag("P1Cam").GetComponent<Cinemachine.CinemachineVirtualCamera>().enabled = true;
    21.             GameObject.FindGameObjectWithTag("P2Cam").GetComponent<Cinemachine.CinemachineVirtualCamera>().enabled = true;
    22.             GameObject.FindGameObjectWithTag("P3Cam").GetComponent<Cinemachine.CinemachineVirtualCamera>().enabled = true;
    23. }
    24.  
     
    Last edited: Apr 8, 2021
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Why would you even want the cameras for every client on all clients? Do you normally want all these cameras active on all clients at the same time? That doesn't make sense.

    If you were going to do it this way, I think you need each client to figure out which camera is theirs, to just enable that 1 camera instead of all of them. What I would really do is only have 1 camera total, the correct camera for just that client. But maybe you're doing something with multiple cameras you haven't explained.
     
  3. sokratos195

    sokratos195

    Joined:
    Jan 23, 2021
    Posts:
    2
    Ty for reply and yes there is no special reason why there is multiple camera's. i did not know it was possible to have 1 camera for every player thats what i get for not watching tutorials. ty i will try to watch tutorials and make 1 camera.

    Edit 1: Sorry i wasn't being clear enough. the 3 players are instantiated with those 3 cameras active and each camera is respective to their own player. but when i disable and enable the cameras like in the script above, only the last player camera's perspective is available for all players. even though all other cameras are activated inspector view i see.

    Edit 2: thats a interesting and nice looking game on your blogspot, reminds me of sid meier's pirates
     
    Last edited: Apr 8, 2021