Search Unity

Cinemachine Orbital transposer with X and Y orbit?

Discussion in 'Cinemachine' started by Abrakidabra, Feb 17, 2020.

  1. Abrakidabra

    Abrakidabra

    Joined:
    May 12, 2017
    Posts:
    62
    I have a cam working great for my game using an Orbtial Transposer with a hard look at in the aim settings. Its responsive and works perfect, except it can only rotate on the X axis. I would like to see round the ship, but also underneath and above to get better angles on the environment.

    My game is a 3rd person space game and I would like my binding to stay as world space so the camera does not rotate weirdly around the player. I tried a framing transposer with POV which was not only very unresponsive and the camera refused to stop accelerating, but also it somehow lost world space up and made it impossible to fly the ship.

    Is there some way I can keep the properties of the orbital transposer while also being able to rotate in the same way in the y axis?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Have you tried using a CinemachineFreeLook ?
     
  3. Abrakidabra

    Abrakidabra

    Joined:
    May 12, 2017
    Posts:
    62
    Thanks for your reply, I felt like that was over complicating what I want, what with the three camera rigs... I really only need one behavior, just a orbit cam that can 360 as opposed to just a 180

    I tried it but I still couldn't get it working in a nice way but I didn't spend that much time on it since i thought there would be a simpler solution
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    You can always write a custom script to attach to your vcam that vertically rotates the orbital's target offset in response to mouse Y input.
     
    Abrakidabra likes this.
  5. Abrakidabra

    Abrakidabra

    Joined:
    May 12, 2017
    Posts:
    62
    Thanks, that's what i done and its working fine.


    Code for anyone interested, attach to virtual camera.




    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using Cinemachine;
    4. public class CamY : MonoBehaviour
    5. {
    6.    
    7.     [SerializeField] private float sensitivityY;
    8.     [SerializeField] private float sensitivityScroll;
    9.     [SerializeField] private float maxZoom = 100;
    10.     [SerializeField] private float minZoom = 20;
    11.     [SerializeField] private float maxYOrbit = 20;
    12.     private CinemachineOrbitalTransposer vcam;
    13.     private float y;
    14.     private float scroll;
    15.    
    16.     void Start()
    17.     {
    18.         vcam = GetComponent<CinemachineVirtualCamera>().GetCinemachineComponent<CinemachineOrbitalTransposer>();
    19.         scroll = -40;
    20.         y = 10;
    21.     }
    22.     void Update()
    23.     {
    24.        
    25.         y -= + Input.GetAxis("Mouse Y") * sensitivityY;
    26.         y = Mathf.Clamp(y, -maxYOrbit, maxYOrbit);
    27.         vcam.m_FollowOffset.y = y;
    28.        scroll += Input.GetAxis("Mouse ScrollWheel") * sensitivityScroll;
    29.        scroll = Mathf.Clamp(scroll, -maxZoom, -minZoom);
    30.         vcam.m_FollowOffset.x = scroll;
    31.         vcam.m_FollowOffset.z = scroll;
    32.     }
    33. }
    34.  
    35.  
    36.  
     
    Last edited: Feb 18, 2020
  6. stgw23

    stgw23

    Joined:
    Dec 12, 2014
    Posts:
    6

    Hi! Sorry, know this is an old post. I have this working with my Camera and now have both X and Y aim, however it seems to have disabled recentering completely. Have I done something wrong or do you know if there's a way around this? Thanks!
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    This is indeed a very old thread, and Cinemachine has added more components since then.
    Try using a vcam with FramingTransposer in Body and POV in Aim. That way you won't need any custom scripts.
     
    stgw23 likes this.
  8. stgw23

    stgw23

    Joined:
    Dec 12, 2014
    Posts:
    6
    Thank you so much for responding, this is exactly what I needed. Will just need to readjust the collider now and should be on my way!
     
    Gregoryl likes this.
  9. Vivraan

    Vivraan

    Joined:
    Feb 2, 2018
    Posts:
    26
    I want to perform a 360 orbit around the look at target. Somehow, FramingTransposer + POV causes the camera to disengage entirely and start looking in a completely different direction:
     
    Last edited: Feb 16, 2022
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Can you show an image of your vcam inspector?