Search Unity

How to rotate a SimpleFollowWithWoldUp Free look camera on X axis ?

Discussion in 'Cinemachine' started by MDemaille, May 23, 2018.

  1. MDemaille

    MDemaille

    Joined:
    Jul 17, 2017
    Posts:
    5
    Hello,

    I'm currently working with Freelook cameras and I have an issue. I want my freelook camera to get the orientation of the camera that I transition from, otherwise the transition is not great because the camera has to go around or through my character to reach it's final position.

    I used to update the m_XAxis.Value and it was working when my Binding Mode was WorldSpace but we now we switched to SimpleFollowWithWorldUp. Updating the m_XAxis.Value seems to not be working anymore on this mode, however we still manage to control the camera during gameplay using the m_InputAxisValue.

    How can I force the FreeLook camera orientation in code ?

    Thank you
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    SimpleFollow is a special binding mode that operates in camera space. Axis value 0 corresponds to the vcam's local forward axis. At the end of every frame, once the vcam has been positioned, the x axis value gets reset to 0.

    That said, if you set the vcam's x axis value to nonzero, the vcam will reposition itself to honor the new heading. So you need to calculate the axis value to set (can't just take it from the outgoing vcam). This value is in degrees relative to the vcam's current forward. So get the outgoing vcam's forward, find its angle relative to the incoming vcam's forward, and set the incoming's x axis value to that.
     
  3. BastienDigixart

    BastienDigixart

    Joined:
    Apr 4, 2017
    Posts:
    13
    @Gregoryl Hello ! We did this but it looks like the value we put is completely ignored by the camera when we are transitionning from a non FreeLook cam to a FreeLook cam. The xAxis value is the correct rotation (in the 0-360 range) but whatever value we put in m_XAxis is ignored anyway.
    We dont modify this value in other part of our code.

    upload_2018-5-23_21-7-26.png

    EDIT : Actually, it doesnt work 100% with the FreeLook neither​
     
    Last edited: May 23, 2018
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    What version of CM are you using?
     
  5. BastienDigixart

    BastienDigixart

    Joined:
    Apr 4, 2017
    Posts:
    13
    We're on the 2.1.10
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    1. At what moment are you calling that bit of code?
    2. What happens when you add the line: newFreeLookCamera.PreviousStateIsValid = false?
    3. What version of Unity are you using?
     
  7. BastienDigixart

    BastienDigixart

    Joined:
    Apr 4, 2017
    Posts:
    13
    1. Breakpoint indicate that yes.
    2. Still the same, it doesnt seem to change anything. But it seem to (kinda) work (80% times) when you switch between FreeLooks but 0% when you switch from a "classical" virtual camera to a FreeLook
    3. We're using 2017.4.2f2
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    But when is it being called? Update? LateUpdate? In an event handler? Give me some idea of the order of operations
     
  9. BastienDigixart

    BastienDigixart

    Joined:
    Apr 4, 2017
    Posts:
    13
    Its called in the Update. And the brain is set in LateUpdate :)
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Hmmm... I can't imagine why this wouldn't be working. Can you put together a small demo project that shows the problem? Then I can help you fix it.
     
  11. BastienDigixart

    BastienDigixart

    Joined:
    Apr 4, 2017
    Posts:
    13
    I will do this asap.
     
    Gregoryl likes this.