Search Unity

Problem with Freelook Camera

Discussion in 'Cinemachine' started by Joofer, Jan 18, 2021.

  1. Joofer

    Joofer

    Joined:
    Jan 5, 2021
    Posts:
    4
    Hi!

    I'm having some trouble using Freelook Camera with Photon PUN 2. As I can see Freelook Camera has an option which changes it's status between live and standby. The problem is when I create a prefab of my player with freelook camera and connect to the game via standolone and editor players see it through the same camera but player controls work correctly. I suppose there's a problem with statuses of cameras because when I try to change it picture goes to the live camera. I have a prefab consisting of 2 cameras one is Freelook and another has Cinemachine brain component. During the game when two players joined I see that 2nd camera points to the live camera even if it belongs to another player.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You need to have only one single Unity Camera (with a CinemachineBrain) in your scene. It sounds like you have one per player. The FreeLook should be aiming at the player. When a second player joins, do not create another camera, unless you are trying to do something like split-screen. Are you trying to do split-screen?
     
  3. Joofer

    Joofer

    Joined:
    Jan 5, 2021
    Posts:
    4
    No, just separate. Thank you, it's helped! But now there's a problem with controllers. I wanted my character to rotate with camera when walking and now there's no object I can get Transform component from and check the rotation.
     
    Last edited: Jan 19, 2021
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Why not use Camera.main?
     
  5. Joofer

    Joofer

    Joined:
    Jan 5, 2021
    Posts:
    4
    Done, it works. Another issue. When there's only one player everything's good but when another one joins the main camera goes to the opposite player that the current player's camera shows another player.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I don't quite understand your description. If you have only one main camera with a CM Brain, and a vcam that's targeting the main player, the camera should stay on the main player, even when a second player joins. Are you also introducing a second vcam which is targeting the second player? Don't do that, unless you want the camera to follow the second player.
     
  7. Joofer

    Joofer

    Joined:
    Jan 5, 2021
    Posts:
    4
    I think I've just solved it. The problem was that all Freelook cameras had the same priority and when second player joined CinmachineBrain switched the first player's camera to the second player's one. I added some code to the script. When prefab is created there's an if which checks PhotonView.IsMine property and if it's true the priority of Freelook camera changed to a higher number. Thanks a lot for your help!
     
    WindBlaze likes this.
  8. Abidtr

    Abidtr

    Joined:
    Feb 3, 2021
    Posts:
    2
    i am having the same problem of camera shifting.can you share the code
     
  9. RenoNicolaou

    RenoNicolaou

    Joined:
    Jun 3, 2022
    Posts:
    1
    I have problem when I create free look camera Status is Standby - not a live (this happened after update unity) When I press play game its look somewhere else where is Main Cam with brain component on it , but when I press Solo it moves on Free look Cam. How I can fix this ?
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Probably you have another FreeLook or VirtualCamera active in your scene. If you look at the Brain inspector, it will tell you which one. When multiple vcams or FreeLooks are active at the same time, CM will pick the one with the highest Priority setting, or if there is more than one with the same highest value, it will take the most-recently-activated one (which is not deterministic, so you want to avoid that situation).