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

Modificar el FOV Cinemachine por script

Discussion in 'Cinemachine' started by Tewasaby, Mar 30, 2021.

  1. Tewasaby

    Tewasaby

    Joined:
    Dec 30, 2018
    Posts:
    6
    using Cinemachine;
    public CinemachineFreeLook VCamera;
    VCamera = GetComponent<CinemachineFreeLook>();
    private void Update()
    {
    if (Input.GetAxis("Mouse ScrollWheel") > 0)
    {

    VCamera.m_Lens.FieldOfView = 80f;
    }
    }

    hola que tal, quería pedirles su ayuda .. necesito que por medio del scroll del mouse pueda modificar la variable de FOV de CinemachineFreeLook pero me da error.
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    I think you'd like to do this:

    Code (CSharp):
    1. using System;
    2. using Cinemachine;
    3. using UnityEngine;
    4. public class FreelookFOV : MonoBehaviour
    5. {
    6.  
    7.     public CinemachineFreeLook VCamera;
    8.     void Start()
    9.     {
    10.         VCamera = GetComponent<CinemachineFreeLook>();
    11.     }
    12.  
    13.     void Update()
    14.     {
    15.         if (Input.GetAxis("Mouse ScrollWheel") > 0)
    16.         {
    17.  
    18.             VCamera.m_Lens.FieldOfView = 80f;
    19.         }
    20.     }
    21. }
    22.  
     
  3. Tewasaby

    Tewasaby

    Joined:
    Dec 30, 2018
    Posts:
    6
    I'm going to look at the code thank you very much friend.