统一控制台每次都显示相同的错误"照相机不具有视野的定义";我用所有的类型写了很多次《视野》,但什么都没发生我试着遵循教程,但总是出现同样的错误我试着改变电影机的视野,但也出现了错误plz帮助。。。。。
这是我的代码:
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;
}
}
}
您试图访问具有错误名称的属性。您正试图将相机的视场属性访问为fieldofview
,您需要将fieldofview
替换为fieldOfView