Search Unity

Forcing a virtual camera to a state (rotation/position) via script

Discussion in 'Cinemachine' started by lucasmontec, Jun 2, 2019.

  1. lucasmontec

    lucasmontec

    Joined:
    Apr 7, 2015
    Posts:
    97
    Hey how are you guys?
    I`m trying to switch between two virtual cameras, an orbital camera and an POV camera. One is a cinemachine freelook camera and the other is a Virtual Camera with a POV 'component'.
    What I want to do is to set the POV camera to have the exact same position and rotation as the orbital camera on the switch. The problem I'm facing is that cinemachine doesn't expose ANYTHING for me to set. Everything is completely hidden and automatic. I have tried setting the virtual camera transform, setting its CameraState raw orientation and calling an update, setting without calling the update and many other things. The camera seems to override any settings I use. Is this achievable with cinemachine at all?
     
    dan_ginovker and adnanzmn97 like this.
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,717
    Try enabling this in the vcams:

    upload_2019-6-4_11-20-5.png

    You can't simply set the vcam transform because, as you have noticed, the vcam will override whatever you do. That's the nature of procedural motion. If you want to manually position vcams, it's possible but you'll have to do a little more work.

    BTW what version of CM are you using?
     
    adnanzmn97 likes this.
  3. lucasmontec

    lucasmontec

    Joined:
    Apr 7, 2015
    Posts:
    97
    I'm using the latest version. The position part is working actually, the rotation part is what I cannot get to work... I need the POV camera to start looking to the same position that the free look was looking at.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,717
    Does it work if you enable InheritPosition?
     
    lucasmontec likes this.
  5. lucasmontec

    lucasmontec

    Joined:
    Apr 7, 2015
    Posts:
    97
    It does! Thanks for this. This name is weird but it makes sense. Kinda hidden and weird since it inherits everything...
     
    Gregoryl likes this.
  6. lucasmontec

    lucasmontec

    Joined:
    Apr 7, 2015
    Posts:
    97
    @Gregoryl
    One last thing... when I change the Time.timescale to anything lower than 1, the game FPS seems to drop. I don't know if it is the FPS or if the camera is stuttering to follow the object. My brain is configured to ignore the timescale and it is set to update on FixedUpdate.
     
  7. lucasmontec

    lucasmontec

    Joined:
    Apr 7, 2015
    Posts:
    97
    Actually I have solved this. It was the object stuttering. Using smart update and setting the object to interpolate the physics movement solved this.
     
    Gregoryl likes this.