Search Unity

How to include camera shoulder offset when doing blending

Discussion in 'Cinemachine' started by CrocsxG, Sep 8, 2021.

  1. CrocsxG

    CrocsxG

    Joined:
    Jan 2, 2018
    Posts:
    6
    I have a Camera A which is free look to allow orbit around the player and movement in all direction :

    I have a Camera B which is VirtualCamera setup as 3rd Person Follow for when the player AIM.


    I would like to transition from A to B and B to A using the blending. All works fine, but when transitioning from B to A I have a problem with the heading.

    I have the following code setup :

    Code (CSharp):
    1.         public void SwitchToFreeLook()
    2.         {
    3.             _isAimMode = false;
    4.             freeLookCinemachine.Priority = 1;
    5.             aimCinemachine.Priority = 0;
    6.             if (_animator)
    7.             {
    8.                 _animator.SetBool("IsAiming", false);
    9.             }
    10.         }

    The problem I face is, A and B have the same target, but while A (free look) do not have a shoulder offset, B does have a shoulder offset. When transitioning from B to A, A will always be set back with an offset.



    It works if I set up recentering in the inspector and keep it on, but I do not which to have that behavior, I tried to add recentering in my switch method, but nothing happened. I can't listen to the blend and reset when it finish because I wish the player to be able to move the camera while blending.

    so I am a bit confused in what would be the best method to fix this issue.

    One thing that is pretty weird to understand is, without changing anything in my code, if I just set the centering like this, so it never trigger but it s still on, and I NEVER call RecenterNow in the code. well, the offset glitch do not happen.
     
    Last edited: Sep 8, 2021
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Switching between FreeLook and 3rdPerson is not the best strategy. You would be better off using two 3rdPerson rigs, as described in this tutorial:

     
  3. ozzyonfire

    ozzyonfire

    Joined:
    Dec 18, 2012
    Posts:
    6
    I had a very similar issue.

    Free Look Cam for normal view.
    3rd Person Cam for zoom view.

    The target object of the 3rd Person Cam was set to follow the rotation of the camera of the Free Look Cam. This meant that I could orient the Free Look Cam and seamlessly blend into the Zoom view so it was pointing exactly where I want it. Perfect!

    The issue I ran into was orientating the 3rd Person Cam while zoomed in and then going back to my normal view, the CM Brain would attempt to reorient my Free Look Cam to the last rotation (i.e. the rotation of the camera when I initially zoomed in) causing some jarring and wonky transitions. Instead, I would have liked it to maintain the rotation of the 3rd Person Cam effectively popping me back out in the same direction I was looking.

    I attempted to set the orientation of the Free Look Cam by code while moving the 3rd Person Cam to no avail.

    The Easy Fix
    The easy fix was just to use 2 3rd Person Cameras like @Gregoryl said, but I actually prefer view of the Free Look Cam. I like being able to have my view look at my character at an angle. 3rd Person Cam seems to only support a flat viewing plane.

    I also like the motion controls (accel time and decel time) of the Free Look Cam, especially when using a Gamepad. I don't know how to do this in the 3rd Person Camera other than coding a custom Acceleration and Deceleration method for my gamepad inputs?

    Is there a way of correctly matching the viewing angle of the Free Look Cam to the 3rd Person Cam? Then when the transition goes from Zoomed in -> Regular View we should avoid the wonky orientations.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Have you tried setting the InheritPosition checkbox in the FreeLook?

    upload_2021-9-17_7-23-26.png

    Also: the 3rdPerson vcam does support rotating around the character, but you have to write a little code in your controller to make it happen. The tutorial video shows how to do this.