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. Dismiss Notice

How to lock the cam rotation to within a range?

Discussion in 'Cinemachine' started by EvilKris, Dec 3, 2020.

  1. EvilKris

    EvilKris

    Joined:
    Nov 18, 2014
    Posts:
    27
    Using LookAt and Aim only is there a way to limit the field of cam rotation? I want to track my character within a certain area but I don't want the camera to follow the character when he passes by the cameras location, and instead switch to another cam in the screen.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    You can write a script to poll the vcam rotation and trigger a switch when it goes out of a specified range.
     
  3. lord_cesco

    lord_cesco

    Joined:
    Mar 9, 2021
    Posts:
    4
    I apologize if this is not the place for asking this:

    Could I change the priority parameter into a ranged attribute?
    I tried over and over but I can't undestand how exactly do, please help me
     
  4. lord_cesco

    lord_cesco

    Joined:
    Mar 9, 2021
    Posts:
    4
    I mean inside the CinemachineVirtualCamera via script
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    Sorry, but I don't understand this question. What exactly would you like to do? Can you give an example?
     
  6. lord_cesco

    lord_cesco

    Joined:
    Mar 9, 2021
    Posts:
    4

    Hi, I wanted to change inside a script the priority parameter of a cinemachineVirtualCamera (now is just an int), into a ranged parameter (I want the priority from 0 to 2 ), I send a image.

    I already undestand how to change that priority with a script but now I need to set boundaries from 0 to 2
     

    Attached Files:

    • gvng.PNG
      gvng.PNG
      File size:
      18.8 KB
      Views:
      266
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    Normally, you would do something like this:
    Code (CSharp):
    1. [Range(0, 2)]
    2. public int m_MyThing;
    However, this will affect only the inspector, it will still be possible to set the priority outside of the range through script.
     
  8. lord_cesco

    lord_cesco

    Joined:
    Mar 9, 2021
    Posts:
    4
    thank you for the clarification :)