Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Problem with high velocity moments

Discussion in 'Cinemachine' started by Zephyros97, Apr 15, 2019.

  1. Zephyros97

    Zephyros97

    Joined:
    Sep 14, 2015
    Posts:
    15
    I ve problem with free look camera when i need to get an high velocity for a moment (dashing).. i want the camera follow my dashes in real time...

    <iframe width="560" height="315" src="
    " frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

    how can i? Maybe can i disable the smoothness during the dash? If yes how can i?

    -Sorry for bad english, i m italian
     
  2. Zephyros97

    Zephyros97

    Joined:
    Sep 14, 2015
    Posts:
    15
    Ok i discovered setting damping to 0 fix it, so how can i change damping values via script?
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,298
    Fai cosi:
    vcam.GetCinemachineComponent<CinemachineComposer>().m_HorizontalDamping = bla;
    anche:
    vcam.GetCinemachineComponent<CinemachineComposer>().m_LookaheadTime = 0;
     
  4. Zephyros97

    Zephyros97

    Joined:
    Sep 14, 2015
    Posts:
    15
    I m using a freelook camera, via script i can only use CinemachineFreeLook there s no functions called GetCinemachineComponent.. i putted a freelook camera with the Cinemachine menu..

    so how can i?
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,298
    Code (CSharp):
    1. for (int i = 0; i < 3; ++i)
    2. {
    3.     CinemachineVirtualCamera vcam = freeLook.GetRig(i);
    4.     vcam.GetCinemachineComponent<...>()...
    5. }
     
  6. Zephyros97

    Zephyros97

    Joined:
    Sep 14, 2015
    Posts:
    15
    mhh it does not change damping values. i m i doing something wrong?

    Top of the code:


    Code (CSharp):
    1. [SerializeField]
    2.     private CinemachineFreeLook soCinemachine;
    Dash function:


    Code (CSharp):
    1. void stateEvade()
    2.     {
    3.         if (!_bEvading)
    4.         {
    5.          
    6.             for (int i = 0; i < 3; i++)
    7.             {
    8.                 CinemachineVirtualCamera vcam = soCinemachine.GetRig(i);
    9.                 vcam.GetCinemachineComponent<CinemachineComposer>().m_HorizontalDamping = 0;
    10.                 vcam.GetCinemachineComponent<CinemachineComposer>().m_VerticalDamping = 0;
    11.                 vcam.GetCinemachineComponent<CinemachineComposer>().m_LookaheadTime = 0;
    12.             }
    13.  
    14.             _vPlayerDash = transform.forward;
    15.             _vPlayerDash.y = 0;
    16.             _oPlayer.velocity = _vPlayerDash * 30;
    17.             _bEvading = true;
    18.         }
    19.  
    20.         if (_oPlayer.velocity == Vector3.zero)
    21.         {
    22.             _bEvading = false;
    23.             _iCurrentState = _ePlayerState.IDLE;
    24.         }
    25.     }
    yes i dragged my freelook camera in that serializefield
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,298
    That should work. Is soCinemachine properly initialized? Does it actually point to the correct FreeLook?
     
  8. Zephyros97

    Zephyros97

    Joined:
    Sep 14, 2015
    Posts:
    15
    This is the damping i want edit



    This is the Freelook in SerializeField:

     
  9. Zephyros97

    Zephyros97

    Joined:
    Sep 14, 2015
    Posts:
    15
    Code (CSharp):
    1. for (int i = 0; i < 3; i++)
    2.             {
    3.                 CinemachineVirtualCamera vcam = soCinemachine.GetRig(i);
    4.                 vcam.GetCinemachineComponent<CinemachineOrbitalTransposer>().m_XDamping = 0;
    5.                 vcam.GetCinemachineComponent<CinemachineOrbitalTransposer>().m_YDamping = 0;
    6.                 vcam.GetCinemachineComponent<CinemachineOrbitalTransposer>().m_ZDamping = 0;
    7.             }
    I Fixed with this, thanks for help <3
     
    Gregoryl likes this.
  10. Zephyros97

    Zephyros97

    Joined:
    Sep 14, 2015
    Posts:
    15
    ok now i ve a new problem, i need to set the dumping when i dash to 0 and when finish to dash again 1, it s ok but the camera need to reposition after changing the value so this make a little graphical problem, so... how can i fix it sir?
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,298
    You could try a coroutine that lerps the value over a short time.

    Another possibility is to have two FreeLooks, with different settings. One for each mode (normal, and dashing). Enable the dash one when the player dashes, and disable it when done. Allow Cinemachine to do the blend. If you choose to do this, then you need to be sure to check the "Inherit Position" of the FreeLooks to make it smooth.

    upload_2019-4-15_17-38-19.png
     
  12. Zephyros97

    Zephyros97

    Joined:
    Sep 14, 2015
    Posts:
    15
    the blend work well for the starting of the dash, at ending has a really bad to see change of camera.... mmh how can i fix it? Sorry for be annoying bro:c
     
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,298
    Can you show me what looks bad?
    And also tell me which method you are using: coroutine lerp or second FreeLook?
     
  14. Zephyros97

    Zephyros97

    Joined:
    Sep 14, 2015
    Posts:
    15


    I used another Freelook, but now it seems work good, i setted Default Bland linear and 0.4 s and it seems to work properly!!

    Best regards bro <3 <3 <3

    ps. are u italian?
     
  15. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,298
    No sono italiano, sono canadese.
    Happy to hear it's working!
    ciao
     
    Zephyros97 likes this.