Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question [Or possible bug?] Cinemachine 3 Pan Tilt axis values don't respect range?

Discussion in 'Cinemachine' started by Rtyper, May 17, 2023.

  1. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    Hey, I'm trying out the new CM3 and wanting to drive the axis value of a Pan/Tilt component directly from my player control script rather than having my input handling split up using an Input Axis Controller. One of my axes has a range defined, but it's ignored entirely when I set the value of an axis directly, i.e.

    cinemachinePanTilt.TiltAxis.Value += cameraInput.y;
    .

    Is this intentional? I see there's a ClampValue method, so I can work around it, but it seems like an unnecessary amount of extra code when I'd expect the clamping to happen automatically. I can't really think of a reason why you'd want to define a range on the component but not use it.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,238
    The InputAxis struct doesn't do any processing, it's meant only to hold data (value, center, range). It's up to the axis driver to enforce the range.

    If you like, you can use the DefaultInputAxisDriver struct in your script to drive the axis based on input values. That will handle all the range enforcing, as well as accel and decel, if you want it.
     
  3. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    Thanks for the quick response. DefaultInputAxisDriver looks like it's doing a lot more than I need it to, so I think I'll stick with applying the range manually for now. Cheers though!
     
    Gregoryl likes this.