-1

每次“相机没有视野定义”时,统一控制台都会向我显示相同的错误我多次重命名视野我用所有类型编写它但没有发生任何事情我尝试按照教程但我总是遇到同样的错误我试图更改电影机 FOV 但我也遇到了错误请帮助.....

这是我的代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations.Rigging;
using Cinemachine;
public class Movements : MonoBehaviour
{
    public GameObject cinemachine;

public Transform Cameratarget;
    public float turnSpeed = 15;
   
    public Camera MainCamera;
    public Animator anim;
    public Camera myCam;
    public Rig aimLayer;
    public float aimDuration = 0.3f;
    public float speed = 14f;
    public float elResitas  = -14f; 
   [SerializeField] Transform ZoomTarget;
    Cinemachine.CinemachineFreeLook elResitas2;
  
    // Start is called before the first frame update
    void Start()
    {
      elResitas2 = cinemachine.GetComponent<CinemachineFreeLook>();
      MainCamera = Camera.main;
        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Locked;
        anim = GetComponent<Animator>();
       myCam = Camera.main;
    }

    // Update is called once per frame
   void FixedUpdate()
{
    
    if (Input.GetKey(KeyCode.Z))
    {
        anim.SetFloat("MoveX",0.17f);
      transform.Translate(new Vector3(0,0,speed)*Time.deltaTime);
      float yawCamera = MainCamera.transform.rotation.eulerAngles.y;
        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, yawCamera, 0), turnSpeed * Time.fixedDeltaTime);
      
    }
    else if (Input.GetKey(KeyCode.S))
    {
        anim.SetFloat("MoveX",-0.166f);
        transform.Translate(new Vector3(0,0,elResitas)*Time.deltaTime);
        float yawCamera = MainCamera.transform.rotation.eulerAngles.y;
        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, yawCamera, 0), turnSpeed * Time.fixedDeltaTime);
    }
    else
    {
        // Only reached if neither Z nor S is pressed!
        anim.SetFloat("MoveX", 0);
    }
    if (Input.GetKey(KeyCode.D))
    {
         anim.SetFloat("MoveZ",0.208f);
      transform.Translate(new Vector3(speed,0,0)*Time.deltaTime);
    }
    else if (Input.GetKey(KeyCode.Q))
    {
        anim.SetFloat("MoveZ",-0.2f);
        transform.Translate(new Vector3(elResitas,0,0)*Time.deltaTime);
    }
    else
    {
        // Only reached if neither Q nor D is pressed!
        anim.SetFloat("MoveZ", 0);
    }
    if (Input.GetKey(KeyCode.Mouse1))
    {
      elResitas2.m_LookAt = ZoomTarget.transform;
 


        speed = 6;
        elResitas = -6;
        aimLayer.weight += Time.deltaTime / aimDuration;
        float yawCamera = MainCamera.transform.rotation.eulerAngles.y;
        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, yawCamera, 0), turnSpeed * Time.fixedDeltaTime);
    }
     else
       {
     myCam.fieldofview = 30;
          elResitas2.m_LookAt = Cameratarget.transform;
           elResitas = -14;
           speed = 14;
           aimLayer.weight -= Time.deltaTime / aimDuration;
       }
     

}
}
4

1 回答 1

0

您正在尝试访问名称错误的属性。您正在尝试访问相机的视野属性fieldofview ,您需要替换fieldofview fieldOfView您使用过的任何地方。

于 2021-04-30T18:57:15.203 回答