Search Unity

Question Spherical Surface Follow-Camera with independent character rotation

Discussion in 'Cinemachine' started by juanrojan1, Sep 10, 2022.

  1. juanrojan1

    juanrojan1

    Joined:
    Sep 10, 2022
    Posts:
    3
    I'm using a vcam with following settings: upload_2022-9-10_16-24-51.png


    as well as setting the correct world up here:
    upload_2022-9-10_16-26-1.png


    The vcam is a child of the target-transform.
    The camera alignment works perfectly, the only problem is that rotating the target/character also rotates the camera. Is there a quick way to fix this or do I need a completely different approach?

    I have seen the SphericalSurfaceFollow demo, but CM FreeLook1/Orbital Transposer feels much worse than a Framing Transposer

    Any help is greatly appreciated!
     
    Last edited: Sep 10, 2022
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,710
    Parenting the vcam to the target in not usually a good idea. Try unparenting it.
     
  3. juanrojan1

    juanrojan1

    Joined:
    Sep 10, 2022
    Posts:
    3
    Thank you for the response!
    Unparenting the vcam causes weird camera flips when changing gravity direction

     
    Last edited: Sep 12, 2022
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,710
    The Cinemachine POV algorithm will set the camera rotation relative to the vcam's parent object. So, if the vcam is a child of the target then the camera will rotate with the target.

    I don't understand what you mean by "gravity flip". How does this relate to the world up override? What do you expect to happen when world up changes?

    If you would like to share your test project with me, it might be easier to find a solution.
     
  5. juanrojan1

    juanrojan1

    Joined:
    Sep 10, 2022
    Posts:
    3
    Sorry for the vague language. "Gravity direction" is constantly being set based on the normal that the character is touching. The "World Up Override" is based on that gravity direction/normal, that way the camera's "up" is always aligned with the current ground normal.
    This is the desired behaviour (I am not moving/controlling the camera when going over the edge, the camera is aligning itself automatically):


    This is using my own camera, but I'd love to use Cinemachine because of all the nice stuff it has

    Thank you for the offer, I'll set up and share a minimal project soon
     
    Last edited: Sep 12, 2022
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,710
    Thanks for the update, I understand what you want.

    I think you can do it by having an invisible object (let's call it GravityContext), as follows:
    • Make your player character a child of GravityContext.
    • Your character controller should move GravityContext instead of the player, but rotate the player to face the desired forward.
    • A custom script on GravityContext takes care of rotating it when it moves over an edge (player child will be automatically carried with it).
    • Use GravityContext as World Up Override in the Brain.
    • Make the vcam a child of GravityContext.
    Also, make sure to use the very latest version of Cinemachine (2.8.9 or, better, 2.9.1). There was a recent bugfix in POV that's relevant to this setup.
     
    juanrojan1 likes this.