Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

State Driven Camera for Over the Shoulder TPS

Discussion in 'Cinemachine' started by ViveLeCommune, Aug 3, 2018.

  1. ViveLeCommune

    ViveLeCommune

    Joined:
    May 2, 2015
    Posts:
    9
    So I'm switching my TPS game project over to the cinemachine system and experimenting with using the state driven camera with different free look cams. The issue is that I think they need to be set to worldspace orbits to work with my setup (I'm rotating the character with the camera), and with worldspace orbits the camera resets its rotation on transition to a new state.

    Is there a way to get around this without code? Or if custom scripting is necessary where's a good place to start?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,389
    Are you using the latest CM from package manager? You should be.
    The code there transfers the axis values on transition between FreeLooks with the same Follow target.
    Also be sure in your use-case to check the "Inherit Position" checkbox:

    upload_2018-8-3_11-56-0.png
     
    ViveLeCommune likes this.
  3. ViveLeCommune

    ViveLeCommune

    Joined:
    May 2, 2015
    Posts:
    9
    I'm using the latest download from the package manager.

    I thought that checking that might fix the issue but I have them checked on all my free look cameras and it hasn't fixed it. The only way I've got it to stop is by switching all my cameras' orbits binding from "worldspace" to "Simple follow with world up", but this causes problems with character control.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,389
    Then I don't understand what's happening. The code in FreeLook does this:
    Code (CSharp):
    1.         public override void OnTransitionFromCamera(
    2.             ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime)
    3.         {
    4.             base.OnTransitionFromCamera(fromCam, worldUp, deltaTime);
    5.             bool forceUpdate = false;
    6.             if (fromCam != null)
    7.             {
    8.                 CinemachineFreeLook freeLookFrom = fromCam as CinemachineFreeLook;
    9.                 if (freeLookFrom != null && freeLookFrom.Follow == Follow)
    10.                 {
    11.                     if (m_BindingMode != CinemachineTransposer.BindingMode.SimpleFollowWithWorldUp)
    12.                         m_XAxis.Value = freeLookFrom.m_XAxis.Value;
    13.                     m_YAxis.Value = freeLookFrom.m_YAxis.Value;
    14.                     forceUpdate = true;
    15.                 }
    16.             }
    17.  
    Maybe there's something weird in your controller?
    Or maybe the Follow targets aren't the same?
    Can you upload a little package that shows the problem?
     
  5. ViveLeCommune

    ViveLeCommune

    Joined:
    May 2, 2015
    Posts:
    9
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,389
    Thanks. Using CM 2.2.7 I see no problems at all on transitions. It's perfect. What version of CM are you using?
     
  7. ViveLeCommune

    ViveLeCommune

    Joined:
    May 2, 2015
    Posts:
    9
    I'm using CM 2.2.0. Sorry, I thought that was the most up to date version.

    How do I get CM 2.2.7?
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,389
    Just open the package manager, it should prompt you to upgrade
     
  9. ViveLeCommune

    ViveLeCommune

    Joined:
    May 2, 2015
    Posts:
    9
    Do I need a newer version of Unity? I've got 2018.2.2 and the package manager says I'm up do date.
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,389
  11. ViveLeCommune

    ViveLeCommune

    Joined:
    May 2, 2015
    Posts:
    9
    That fixed it! Thank you so much for helping me out!