Search Unity

Cinemachine Free Look - How to achieve linear speed for Axis Controls?

Discussion in 'Cinemachine' started by xDavidLeon, Aug 30, 2018.

  1. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    123
    Hi there,

    Cinemachine is an amazing tool, but I'm having issues achieving some basic functionality that can be done with very simple alternatives.

    The first issue is that I can't find a way to get linear camera velocity when moving the camera vertically around the target.

    With the Free Look component, the Y axis, which goes from 0 to 1, defines the vertical positioning of the camera. So, 0 places the camera at the Bottom Rig position, and 1 places it at the Top Rig position. The issue is that when I move the controller / mouse down or up, the camera velocity will differ depending on the distance between the rigs.

    Using this extreme example:


    The camera will move way faster from the top rig to the middle rig than from the bottom rig to the middle rig, and that makes the camera feel really clunky when playing.

    The 2nd big issue is the way the spline works here. When the camera travels to the bot rig position I would expect it to use the Bottom rig position as the lowest Y position in its path, but as you can see in the screenshot this is far from reality.

    If you could shed some light into these issues I would be super happy.

    Kind Regards,
    - David L
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    The first problem is due to the 0 value of the Y axis corresponding to the middle orbit, and the fact that the camera has farther to travel on the top portion of the spline. Axis velocity is in Axis units per second, not distance per second. One way out is to try to make the path lengths of both halves of the spline approximately the same, by placing the middle orbit closer to the middle, and not so close to the bottom. Another possible solution is to have a middle-man script driving the axis. Add a script to manipulate the Y axis value in a custom manner.

    For the second thing, I think it's just spline tension. Have you tried lowering it?
     
  3. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    123
    Hey Gregoryl,

    Yes, I figured that the 1st issue is part of how the Free Look Camera works. Making both halves of the spline similar in length beats the purpose of the tool from a UX perspective; I tried it anyway and gave me other issues, since then I cannot define the exact height/radius of the orbit centered around the player's head (what should be the mid orbit). I was also trying to find a way to redefine the spline by hand with no success. I'm really surprised that nobody else has given any feedback regarding vertical camera movement/speed.

    I ended up coding my own gameplay free look cam, and using a Cinemachine External Camera to make it play nice with the rest of Cinemachine virtual cameras.

    Thanks
     
  4. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    Hi @xDavidLeon glad to hear you're up and running. I'd be really happy to hear what you did in your custom FL version. Was it just

    - Head orbit radius
    - Crafting new spline shapes?

    We are working on FreeLook2 which is getting close to ready and I'd like to make sure it addresses as many issues/features as makes sense. Would love to know what you did on your specific FL.
     
  5. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    123
    I'm attaching the package with the GameObject structure for the camera rig, and my FreeLookCam script. You'll probably need to remove some lines referencing my Rewired input implementation etc.

    The usual config uses only 2 GameObjects.
    1. CameraRig prefab with the FreeLookCam script.
    2. Camera GameObject with Cinemachine Brain and Cinemachine External Camera component.
    Let me know if you have any issues.
     

    Attached Files:

    ZiadJ and Adam_Myhill like this.
  6. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    Awesome, thanks for sharing. Very much appreciated.