Search Unity

Camera Aim Involuntarily Changing on Play

Discussion in 'Cinemachine' started by bodhi_berry, Mar 9, 2020.

  1. bodhi_berry

    bodhi_berry

    Joined:
    Feb 13, 2017
    Posts:
    8
    Hi!

    Downloaded Cinemachine a week ago and have had a persistent problem since of my camera's aim changing whenever I hit play.

    I set my aim composition to center on an object, but as soon as I enter Play Mode, the camera is automatically adjusted down and to the left and the object originally aimed at is set to the top right corner of the view.

    This issue had also begun to affect every camera in my project - not just the ones with a VirtualCamera or Brain attached to them.
    I tried deleting amd reinstalling Cinemachine and the problem persisted.

    I'll attach a video to show exactly what is going on.



    Any help would really be appreciated, this bug is hardcore handicapping my development.

    Also this additional error if anyone has a solutions:
    Cannot set field of view on camera with name 'BattleIsWon Camera' while VR is enabled.
    UnityEngine.Camera:set_fieldOfView(Single)
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    From the docs: https://docs.unity3d.com/ScriptReference/Camera-fieldOfView.html
    "Some VR SDKs have fixed field of view values that are used for VR cameras. When VR is enabled with those SDKs, this property will always return the value from the SDK. You will see a warning logged if you attempt to set the [field of view] property and the value will be ignored."
     
    Last edited: Mar 9, 2020
  3. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    The other issue, it seems to me, that you positioning your main camera by hand, and then when you hit play cinemachine vcam takes over and puts it where it's settings want it to be.
    Try positioning your main camera through your vcam's settings.

    If that's not the case, could you send me a project where I can reproduce the issue?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
  5. bodhi_berry

    bodhi_berry

    Joined:
    Feb 13, 2017
    Posts:
    8
    Hi, thank you for the replies!

    gaborkb, I tried that and the same issue still occurred. No matter how the cinemachine is positioned or set up, once I press play the camera still moves down and to the left.
    As for the FOV issue, I can't seem to find where the FOV is being changed. I believe it has something to do with Cinemachine as well.

    Greg, the cameras impacted by this issue are not connected to any VR objects or components in the scene.
    The VR cameras actually seem to be the only ones not misplaced on play.
    (thanks for the link though, I'll check it out if I ever do dare to combine the two!)

    I'll send you both a project to peek around on. And will keep looking in to it myself.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Perhaps you have not properly separated the VR stuff from the CM stuff. Can you explain your setup a bit, so I understand what the VR is supposed to do and what CM is supposed to do? Even better, can you show me a picture of your project hierarchy, with the cameras/CM/VR objects visible?

    I won't be able to reproduce with your project because I don't have a VR setup on my computer right now.
     
  7. bodhi_berry

    bodhi_berry

    Joined:
    Feb 13, 2017
    Posts:
    8
    I removed all VR elements from the scene and the issue persisted.

    But then I tried removing the Oculus XR Plugin from XR Plugin Management and the issue was fixed! Camera stayed where it was aiming.

    Thanks for the solution! Do you have any idea why the Oculus XR Plugin being active in the project would have this effect on my cameras? Would love to use both VR and non-VR cameras in the scene.

    Here is a screencap of my project hierarchy with no VR cameras listed. (with this hierarchy; issue persisted with Oculus XR plugin on and was fixed with removing it from my Plugin Providers)
     

    Attached Files:

  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    I'm guessing that the Oculus XR plugin grabs the first Camera it finds and takes control of it. Possibly a solution is to have a second Camera that you use with CM. Disable the first one when not using XR. Did you try with 2 cameras?

    Also, you might want to poke around in the Oculus docs to see if there's a way to programmatically disable it for dual-mode applications. Surely there must be.
     
    Last edited: Mar 12, 2020
  9. bodhi_berry

    bodhi_berry

    Joined:
    Feb 13, 2017
    Posts:
    8
    Tried with a series of different amounts of cameras and hierarchies in the scene - none worked. It seems to have this affect on every camera that I put into the scene whenever the Oculus plugin is active.

    I'll start digging through the documentation and update here if I find anything!
     
    CosmicStud and Gregoryl like this.
  10. CosmicStud

    CosmicStud

    Joined:
    Jun 13, 2017
    Posts:
    55
    @gaborkb @Gregoryl Yeah seems to be an issue with me as well, is there a way to stop Cinemachine from changing the value? It outputs the warning every frame I think
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    One way is to put the CinemachineBrain not on the Camera object, but on the GameObject parent of the camera. Then, the CM brain will drive only the transform, and will not attempt to set any lens values.
     
    CosmicStud likes this.