Search Unity

How to copy values from Main Camera to vCam?

Discussion in 'Cinemachine' started by el_Guero, Jun 3, 2021.

  1. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    It's very easy to set up a camera to a needed angle and position in the scene view. With Command+Shift+F even easier by simply aligning the camera with the scene view.

    Is there a way to copy these settings into a Vcam? Because there's no way to 'physically' move a Vcam around or is there? I'd so love to be able to set the main camera and then just have the Vcam somehow copy and translating it over to its own settings.

    Possible? Or something that is close to it?
     
  2. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    I do my workflow a little differently. The important thing to remember here is that until a VCam is constrained by a Follow or Look At, it's really just a GameObject and can move around like any GameObject.

    Also note that I have keyboard shortcuts assigned to "Create Virtual Camera", "GameObject > Align with View", and "GameObject > Align View To Selected". This gives me instant keyboard access to everything I need to work quickly on a scene.
    1. In Scene View, navigate to the view you want.
    2. Create a new VCam. The Camera will align itself to this newly created Vcam exactly where your Scene View is.
    3. If I'm not quite on target, I'll navigate in the Scene View, then GameObject > Move To View to put the VCam (and therefore the Camera) exactly where I want.
    4. Sometimes I want to make tweaks on a VCam using the Scene gizmos. When that happens, I navigate away from the VCam, then make my tweaks. If I want to get back to the VCam's perspective, I choose GameObject > Align View To Selected (you can see why the keyboard shortcuts are so handy).
    5. Rinse and repeat.
    Essentially, I'm just creating a lot of VCam "bookmarks". Whichever VCam has highest priority will take control of the camera. Then, in my game or movie, I set the camera priority or use Timeline to indicate which VCam the camera should obey at any given moment.

    Hope that helps!
     
    Last edited: Jun 4, 2021
    gaborkb likes this.
  3. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    Thanks Marc for your reply, the problem is though when you have a Vcam constrained by a Follow or Look At and which is what I meant in my first post.

    How can I have - lets say - the player attached to both and yet still easily set the position and the rotation of the camera like if it was with the Command+Shift+F shortcut?

    There must be an easy setup, right? Setting the cameras position/rotation in the inspector is confusing at best.
     
  4. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    In fact, how can you set up - for example - the rotation of the Vcam without affecting the offset? I can't just position the camera to a 45 degree roation and give it a distance without losing the center point, then I need to adjust the offset. All this doesn't make much sense to me.

    Why is it not possible just to position/rotate the camera and have the other needed settings applied automatically?
     
  5. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    What you're describing really isn't how how Cinemachine works (it's kind of the opposite). The whole point of constraining is to limit the places a camera can be and the direction the camera can look. So even if there were a control to copy all data from the Camera to the VCam, the constraints would instantly override that action.

    This is conceivable, but it's also neither easy to implement nor guaranteed to deliver the result you expect. There are a lot of inter-operating controls in Cinemachine to get the behavior you want. So simply moving/rotating the camera doesn't tell us, for example, what kind of framing you want, or precisely how the camera should act as the target(s) move.

    We're certainly aware that Cinemachine is better in the power-of-the-tool department than in the area of ease-of-use. We're looking at ways to improve how the UI informs you of what you can and cannot do. This will likely include some scene view/game view handles to make what you're trying to do easier.
     
    el_Guero likes this.
  6. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    I understand the part of constraints and target's moving. If you look at it from a cinematographic angle, it's all about the framing. So you set the follow target and the look at target. Then the camera's position and rotation.

    But there is no simple way of doing that. Scene view handles would be cool for sure, but even if not, why there isn't a simple way to just set the position and most of all the rotation of the camera is really not understandable.

    There is an offset and a camera distance. No explanation what's the difference whatsoever. And when you rotate the camera you need to re-adjust the offset. If the Vcam already knows the target, why doesn't it do this automatically?
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    If you want a static vcam whose position and rotation you set manually, that's easy. Navigate the scene view camera the way you want it, then create a vcam. It will have the same position and rotation as the scene view. If you want to reposition an existing vcam, navigate the scene view camera, then select your vcam and press ctrl+shift+F. There are also a couple of menu entries in the vcam inspector:

    upload_2021-6-8_6-8-35.png

    Set the Aim and Body settings of the vcam to Do Nothing. That will eliminate the warnings and turn off all procedural tracking. Setting the LookAt and Follow targets to nothing will also turn off procedural tracking.

    Without procedural tracking, you can adjust the position and rotation of the vcam directly and simply, just as you would a normal camera.

    You haven't mentioned what the "Body" and "Aim" settings of your vcam are. That would help us understand what you're trying to do. For now, I'll assume that you're using the default Transposer and Composer.

    If you give the vcam a Follow target and a Body setting other than Do Nothing, you're asking it to position itself in relation to a Follow target, and to keep following it, no matter how that target moves. In this case, you're relinquishing direct control of the camera's position and instead are adopting indirect control: you have to tell the vcam what to follow and how to follow it. The "what" is the Follow target, and the "how" is the follow offset.

    upload_2021-6-8_6-14-45.png

    With this camera setting, you no longer can control the vcam's position directly. If you try to change the transform, the vcam won't allow it because it's in conflict with the instructions you've given it.

    However, it is possible to drag the transform gizmo in the scene view to adjust the position. The vcam will interpret that as a refinement of the follow offset, and the change will be applied to the follow offset:

    upload_2021-6-8_6-20-50.png upload_2021-6-8_6-21-28.png

    The same logic applies to the LookAt target and the Aim section of the vcam. You don't have to give the vcam a LookAt target, but if you do, you're telling it to look at that thing. That means: rotate the camera so that thing is in the center of the screen, and keep looking at it no matter where that thing goes. If you don't want to look directly at that thing's center, then you set the Tracked Object Offset to indicate the point of interest that you actually want to look at. "Look at" by default means: "put that point in the center of the screen".

    upload_2021-6-8_6-27-14.png

    Once you've established the point of interest, you may choose not to put it in the center of the screen. Similar to situation with position, you can't just directly rotate the vcam. You have to tell it where on the screen to put the point of interest. You do that with the Screen X and Screen Y settings in the Aim section of the inspector. Unfortunately there is no scene view shortcut for this, because if you tried to rotate the vcam, it wouldn't know whether you want to change the ScreenX/Y or the Tracked Object Offset.

    It's hard to tell from your post whether you want the vcams to continually track your targets, or whether you're just using CM as a convenience to set up non-tracking vcams. In the latter case, you can assign a LookAt target to initially look somewhere, then immediately remove the LookAt target, allowing you to manually adjust the rotation. In that case, the camera will return to manual control and won't track the target. Maybe that's what you want.
     
    Last edited: Jun 8, 2021
  8. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    Thanks for that explanation. It definitely helps to understand its logic.

    And yes, I'm continuously tracking both, follow and look at. What is missing is the way you rotate the Vcam without having it offset from the center point. Like looking at the object in a constant 45 degree angle from a little bit above. So you need to rotate it on two axis.

    I do this right now with a Cinemachine Recomposer component applying tilt and pan. There's no way to set this up with the Vcam component itself, right?

    And for example for a rotate around the object (orbit) you would need a dolly vcam, right?
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    @el_Guero What Body and Aim components do you have on the vcam?
     
  10. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    I have a game setup with Framing Transposer Body and Aim Same as Follow Target and another one with only Transposer Body and Aim at Same as Follow Target too.
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    In the Framing Transposer vcam, why do you need the "Same as Follow Target" in the aim? If you put "Do Nothing" in the aim, then you can freely control the angle using the vcam's transform, because the vcam won't be procedurally controlling it. You won't need Recomposer. In that case, orbiting is as simple as changing the vcam's Y rotation.

    What kind of movement are you trying to get with the Transposer + Same as Follow Target vcam?
     
  12. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    In this case I have a player moving in an orbit and the camera is always placed behind it. If I set the Aim at Do Nothing it doesn't rotate with the player around that orbit.

    A simple movement following the player in all 3 axes with a little bit of damping, and small dead/soft zone. Angle always from the same point. Meaning it shouldn't rotate with the player.
     
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Well, the SameAsFollowTarget aim is very restrictive - it locks the vcam's Forward axis, and doesn't leave any room for adjustment. It might be interesting to let go of that one. Transposer + Composer might give you more flexibility. You can adjust Composer's screen X/Y directly in the Game View by dragging the little yellow dot. Set the Binding Mode to LockToTargetWithWorldUp for the first vcam, and WorldSpace for the second.
     
  14. CogumeloSoft

    CogumeloSoft

    Joined:
    Dec 28, 2012
    Posts:
    88
    This was my solution for the problem of setting the Vcam to a specific position


    Code (CSharp):
    1.  
    2. StartCoroutine(ForceCameraPosition(value));
    3.  
    4. IEnumerator ForceCameraPosition(Vector3 value)
    5.     {
    6.         Manager_CameraWorld.manager.brain.enabled = false;
    7.         Manager_CameraWorld.manager.brain.gameObject.transform.position = value;
    8.         yield return new WaitForEndOfFrame();
    9.         Manager_CameraWorld.manager.brain.enabled = true;
    10.     }
    11.