Search Unity

FreeLook camera with secondary target

Discussion in 'Cinemachine' started by Grhyll, Nov 23, 2017.

  1. Grhyll

    Grhyll

    Joined:
    Oct 15, 2012
    Posts:
    119
    Hi!

    Couldn't find how to do this, so I suspect it may be a bit too specific, but I'm still gonna ask just in case there's a way to achieve what I'm looking for easiliy :)
    My goal: a free look camera (orbiting around a given transform, automatically aligning to its forward after a delay) that also keeps another transform target in the field (either via fov or orbit radius auto adjustment).
    Well, just writing it, I can see how odd and vague it can look, but hey, so far I've been surprised by quite a lot of the features Cinemachine offers, so... :D
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    You could try using a CinemachneTargetGroup. Put both your targets in there, and assign the group as the FreeLook target. A little weird, but it might work.
     
  3. Grhyll

    Grhyll

    Joined:
    Oct 15, 2012
    Posts:
    119
    I tried to use the target groups, but no success. I really want the camera to be centered on the first target, and follow it. The secondary target should just be included in the shot, but it can be on the side, it should only impact on the camera fov or distance from the main target, not its orientation.
     
  4. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    Hi @Grhyll that's some pretty specific behaviour. We've built CM to be as versatile as possible and with an open API so you can get in there and customize it as needed for specific results.

    Changing the distance or FOV of a free-look to keep a secondary target onscreen is an interesting idea - it could cause issues with increasing the free-look radius...

    The Target Group idea Gregory mentioned is one method - make sure to set your free-look Aim to be Group Composer, which exposes the extra framing logic with FOV and dolly in/out controls.

    I can't say I've tried this approach... it's a bit crazy but definitely worth trying again if you didn't mess with the Aim / Group Composer bits.
    upload_2017-11-24_8-29-11.png

    Outside of that, in similar situations I've had good luck with blending to larger / wider lens free-looks when secondary target(s) come into play - like turning on a 'bigger free-look' vcam every time an enemy appears, etc.
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Here's another thing you might try: if you want to stay centered on your main target, you could make a special kind of group as follows: use a Target Group with 2 members: your main target with weight 1, and your secondary target with weight 0. Attach a little script which, every update, sets the radius (in the group) of the main target to be the distance between the main target and the secondary target. That will fool the Group Composer into keeping both in frame, while remaining centered on the main one.
     
  6. Grhyll

    Grhyll

    Joined:
    Oct 15, 2012
    Posts:
    119
    Thanks a lot for the suggestions, I really appreciate! Gonna try both methods when I get the chance, and I'll keep the thread updated with the results :)
     
    Adam_Myhill likes this.
  7. Grhyll

    Grhyll

    Joined:
    Oct 15, 2012
    Posts:
    119
    So here's my report: there's definitely something to do with your suggestions. Changing the aim to Group Composer gives very good results on the frame, and updating the main target radius in the group improves it a bit more. Now The camera movement are sometimes a bit jerky when moving the main target, but I suppose it's due to the fact that I'm not familiar enough with the various parameters exposed by the cinemachine camera, so I'm going to watch a few more videos (I've seen that some new ones have been uploaded).
    Thanks a lot for your help!
     
    Adam_Myhill likes this.
  8. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Turning on a separate camera that does the same stuff but with different aim/composition parameters.
    That is an awesome idea, I didn't even think about that! It's so much more elegant and intuitive than than the old/naive way (having different camera modes and presets all clumped into one script)

    I realize now that Cinemachine totally changes how we have to think about cameras and how to work with them, ... (in a good way!) (I mean after ages of being in a mindset of "how do I manipulate my one single camera do do those things")

    It's probably not all that complex once you're working with cinemachine for a while, but if you have any more interesting setups like that, let us users know :)
     
    Grhyll and Gregoryl like this.