Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Questions about the basic approach to implementing FreeLook cameras

Discussion in 'Cinemachine' started by seoyeon222222, Mar 28, 2021.

  1. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    176
    hello
    I'm a beginner who doesn't have much experience with a cinemachine
    I want to make a basic camera like below through a cinemachine

    I tried to solve this problem through "FreeLook Camera"
    (I don't know if this is the right approach)
    But it had some big differences from what i wanted.

    I want to know the appropriate approach or keywords to solve this problem.

    here is the basic camera action that i want to make.
    (https://files.catbox.moe/kbofd2.webp)


    It is a simple character camera used in a typical mmorpg, etc.

    1. The camera rotates releative to the obeject according to the movement of the mouse
    and can see the object

    2. can Zoom in/out

    3. Even if the object is moved, camera's gaze is fixed
    (follow the target, but direction does net change)

    4. Lower mouse down, eyes get closer to the floor.
    continue lower mouse down, camera will be closer to the object and gaze will change.
    ( https://files.catbox.moe/iq182m.webp )


    This is a more detailed description of the conditions 4.
    camera moving when the eyes go down.

    if return to original gaze, existing zoom in/out distance must be maintained.


    I was able to make similar movements through the freelook,
    However, i can't subtly satisfied with the above conditions.

    What is name for this type of camera?
    What method of approach is appropriate to implement this camera?
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hi
    You are on the right track, freelook seems to be a good fit for your needs ;)

    In the Freelook vcam inspector: set Orbits -> Binding Mode to Lock To Target. This will make the camera stay behind the target.
    BindingMode.png

    If you do not want to move the camera around your target with your mouse, instead you'd like to control the target's rotation directly with your mouse. Then disable the mouse control on the X axis on the freelook.
    XAxis.png

    In the Orbits section, scale the radiuses of TopRig, MiddleRig and BottomRig. For example, if your radiuses are 2, 3, 2, then changing them to 4, 6, 4 will result in a 2x zoom out, and changing them to 1, 1.5, 1 will result in a 2x zoom in.

    If I understand correctly, you'd like to turn off damping. You have TopRig, MiddleRig and BottomRig. Turn off the dampings on them. I am not sure which ones you'd like off, so play around with them until you have what you'd like.
    Damping.png

    This is achieved by having smaller radius for the BottomRig than the MiddleRig. If you have your Freelook camera selected, then you will see a red gizmo drawn in the scene view. This visualizes the rigs of Freelook.
    Rigs.png

    If you need more info or clarification, please reach out ;)
     
    seoyeon222222 likes this.
  3. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    176

    ------------------------------------

    Thank you very much for your kind and quick reply :)

    Add some information about my incorrect question.

    This is the trajectory of the camera operation that i want.
    (https://files.catbox.moe/fomsgp.gif)

    This is the form of zoom in/out
    (https://files.catbox.moe/ts936f.gif)

    Based on this movement,
    This is the image that expresses it like the trajectory of a cinemachine FreeLook
    upload_2021-3-30_6-52-8.png
    As shown in the attached gif,
    - distance between the highest and furthest positions is the same
    - create a circular orbit
    - From the moment the camera touches the floor,
    the camera gets closer to the character and heads up

    i tried to reproduce this as cinemachine FreeLook

    upload_2021-3-30_6-54-3.png

    changed radius of Top, Bottom Rig to 0(or 0.01)
    changed radius of MiddleRig and height of TopRig to make a same distance.
    upload_2021-3-30_6-56-29.png

    But the shape of the curve showed a lot of difference.
    In fact, the camera has a problem that goes down through the ground.
    To resolve this, i use Spline Curvature option, but it couldn't solve the problem.

    How do i reproduce this camera work?



    one of the questions i misinterpreted,
    "camera follows without being affected by the character's movement"
    was solved by setting Binding Mode to World Space.



    For zoom In/Out, i wrote script.
    receive events of mouse wheel and manually change the value of
    Top, Middle, Bottom Rig's Radius and Height.
    It's behavior was not fluid and made me wonder if this was the right way..
    is there are any zom in/out function without using custom script?
     
  4. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Try this script (taken from here: https://forum.unity.com/threads/cinemachine-how-to-add-zoom-control-to-freelook-camera.505541/)
    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using System.Text;
    5. using Cinemachine;
    6. using UnityEngine;
    7. namespace Test
    8. {
    9.     [RequireComponent(typeof(CinemachineFreeLook))]
    10.     class CinemachineFreeLookZoom : MonoBehaviour
    11.     {
    12.         private CinemachineFreeLook freelook;
    13.         private CinemachineFreeLook.Orbit[] originalOrbits;
    14.         [Range(0.0F, 1F)]
    15.         public float zoomPercent;
    16.         public void Awake()
    17.         {
    18.             freelook = GetComponentInChildren<CinemachineFreeLook>();
    19.             originalOrbits = new CinemachineFreeLook.Orbit[freelook.m_Orbits.Length];
    20.          
    21.             for (int i = 0; i < freelook.m_Orbits.Length; i++)
    22.             {
    23.                 originalOrbits[i].m_Height = freelook.m_Orbits[i].m_Height;
    24.                 originalOrbits[i].m_Radius = freelook.m_Orbits[i].m_Radius;
    25.             }
    26.         }
    27.         public void Update()
    28.         {
    29.             for (int i = 0; i < freelook.m_Orbits.Length; i++)
    30.             {
    31.                 freelook.m_Orbits[i].m_Height = originalOrbits[i].m_Height * zoomPercent;
    32.                 freelook.m_Orbits[i].m_Radius = originalOrbits[i].m_Radius * zoomPercent;
    33.             }
    34.         }
    35.     }
    36. }
     
    seoyeon222222 likes this.
  5. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Great, that makes sense :)
     
    seoyeon222222 likes this.
  6. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    It is a bit tricky, because your path is not smooth. It has a curve and a line. So I suggest building it in to parts like this:
    You can create the curvy part using the rigs (top, middle, bottom), and to get the straight line add a CinemachineCollider (Add Extension -> CinemachineCollider) with Pull Camera Forward Strategy.

    For example:
    If you create the rigs using these settings
    FreelookSetup.png
    then you'll get the following curve
    FreelookVisual.png

    Notice that the curve goes below the ground. This is the part where the collider is going to do its job pulling the camera towards the player in a straight line.
    CMCollider.png
     
    seoyeon222222 likes this.
  7. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    176
    ----------------

    Wow !!!! Thank you!

    Perhaps i couldn't solve this by my self.
    Your answer was very helpful to me

    I hope something good happens to your team :)
    thanks!
     
    gaborkb likes this.