Search Unity

Difficulties Recreating Camera System to Cinemachine Camera System

Discussion in 'Cinemachine' started by Zyrathius, Oct 10, 2018.

  1. Zyrathius

    Zyrathius

    Joined:
    Dec 18, 2012
    Posts:
    20
    Hi Guys,

    Firstly, love Cinemachine so far. The transitions are amazing! I'm new to using/posting to forums, so still learning these tools, sorry if the post is messy.

    Ok, so finally have had some time to try converting my legacy camera system over to Cinemachine. It has been giving me fits thus far trying to recreate some of the things I was previously doing. I believe it's mostly related to either my setup or how I'm try to talk to them in Cinemachine.

    Previous legacy setup was a camera which orbited around a specific target. I have code that moves the specific target around from various objects during runtime. So the net effect is you can move from object(s) to object(s) and always have an orbiting camera that is able to zoom in and out with the mouse wheel.

    This legacy setup I felt was closest to the new Cinemachine Free Look Camera system and so I tried to setup something similar using the FreeLook and with the help of some code in another thread from @Gregoryl managed to get the mouse wheel zooming in and out as well. Works and looks really nice so far.

    So the problem begins when I have tried to implement the additional features of my old camera system. I had a function that would calculate the bounds of every object or objects you wanted to "highlight" the users focus on and pass to the orbiting camera and so it would then adjust it's distance from the objects so that they fit in view. This was the initial behavior when the function fired, but at any point after the user could then override and resume zooming in or out and orbiting again. It is this behavior I have been struggling to implement.

    Initially tried making a couple of functions that would calculate a % of the min/max distance using my old camera and then attempted to apply the % to min/max scale of the Cinemachine Freelook orbits. I could not get this to work, it seemed like it maybe was being ignored or overwritten by the update perhaps.

    I also attempted utilizing the TargetGroup functionality and dynamically adjusting the target radius at runtime, which seems like it semi works however the camera is no longer as smooth and allowed to completely orbit like before. Additionally it also controls the zoom such that once it fills the view, when I zoom in and out the view stays more or less the same as the camera moves.

    What would be the best camera/cinemachine setup to achieve what I'm trying to do? I feel like I may have the best setup, but not connecting the pieces properly. Though perhaps a different Cinemachine vcam setup or multiple vcams would work better as a starting point?

    Also, If there is a tutorial or example that illustrates a similar setup, I would appreciate a link or point to the right direction. Thank you.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,725
    Sorry, no tutorials for this specific setup.

    If you're controlling the zoom manually, then you will definitely be fighting with the Group Composer, so TargetGroup isn't the way to go.

    I like this approach. Can you go into a little more detail about how you implemented it? Maybe we can locate the blocking issue.