Search Unity

Rotate camera on the Y axis

Discussion in 'Cinemachine' started by Tinniman, May 9, 2022.

  1. Tinniman

    Tinniman

    Joined:
    Dec 14, 2020
    Posts:
    49
    Hi.
    I am new to Cinemachine and Unity but like what I have achieved so far. My character is a car and I am using virtual camera to have the camera follow it. It works fine.

    Still, I have an issue I hope you guys can help me with:)

    In order to travel around the world I need to have buttons (and keyboard) be able to control the Y axis for the camera. I have no clue about coding so I am hoping there is an easy solution like in visual scripting or playmaker.

    I am moving my project from Buildbox to Unity and I have attached a video file ( from BB) that shows what I am trying to achieve.

    Rotate camera in BB:
    https://drive.google.com/file/d/1ZLT84fiY6b-2LM51WofPbyozG4ogvyyq/view

    Hope someone replies:)
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    If you put OrbitalTransposer in the Body section of the vcam, then it will expose a rotation axis that you can connect to the input system. By default it will be set to "Mouse X" but you can change it so that a different input source controls it.

    upload_2022-5-10_11-59-54.png
     
  3. Tinniman

    Tinniman

    Joined:
    Dec 14, 2020
    Posts:
    49
    Thanks for the reply!
    Some questions:
    1. When I do this the camera start to rotate in akward ways when driving. ( I can post a video). I was behaving perfect when I used framing focus. I want it to not rotate at all but only with butttons. Like the video I posted.
    2. Can it be controlled with two buttons back and forth?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Do you have WorldSpace binding mode (as in my image)?
     
  5. Tinniman

    Tinniman

    Joined:
    Dec 14, 2020
    Posts:
    49
    Yes. Weird behaviour. The camera does not follow the car but just moves directly forward. If I touch the mouse the camera still does not follow but takes large turns around the screen.

    The effect I´d like is close to having Framing Transposer but be able to add some controls to the transpose Y axis that is located over the cinemachine component. Turning this around will orbit the camera 360 degrees with the same distance to the car.
     
  6. Tinniman

    Tinniman

    Joined:
    Dec 14, 2020
    Posts:
    49
  7. Tinniman

    Tinniman

    Joined:
    Dec 14, 2020
    Posts:
    49
    Do you have a good solution Gregoryl?
    I manage to rotate the Y axis on the camera with buttons but compared to the video I shown, it will take in the fact that I have rotated the x axis and therefor it skews around the car and not rotate only on the y axis. I need the camera to rotate only on the Y axis and ignore the other axis.
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Sorry I am away from my computer and can’t see the details in the videos. I suspect that you have set up the vcam and target in some unexpected way. Can you post images of the inspectors and hierarchy?
     
  9. Tinniman

    Tinniman

    Joined:
    Dec 14, 2020
    Posts:
    49
    Okay so here are some pictures. I have set a red circle around the Y axis. If I rotate this in play mode with my mouse, everything work like I want. My problem is that I dont know how to force rotate only this axis as when I use set up my rotate with buttons and keyboard the rotate take in the fact that I have cinemachine rotated on the x axis. So when rotating its not rotating around Y axis but also around X axis. That was what I made video of.



    https://www.dropbox.com/sh/hc6xc6j48fny0hc/AAAb4hU6XMhOQWF5nR3UyYxga?dl=0
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I have seen the videos now. It looks as though in your OrbitalTransposer setup you have used the wrong Follow target, or something like that, or you have other code interfering. Certainly the behaviour is very weird and not at all typical of a correctly setup orbital camera. I can't tell from the hierarchy you have shown, there is not enough detail. Why isn't the orbital's Follow target "Car Body", same as FramingTransposer?

    You can make the Framing Transposer solution work very easily by having the buttons modify the Y rotation of the vcam's transform, same as you are doing by hand. The X rotation should make no difference.
     
    Last edited: May 16, 2022
  11. Tinniman

    Tinniman

    Joined:
    Dec 14, 2020
    Posts:
    49
    Hi, I did it. I just had to rotate limit the camera to not turn on X and Z:) I now have Framing transposer working with buttons to adjust the Y axis correctly:)
     
    Gregoryl likes this.