using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class camMouseLook : MonoBehaviour {
protected Transform XForm_camera;
protected Transform XForm_Parent;
protected Vector3 LocalRotation;
protected float CameraDistance = 10f;
public float MouseSensitivity = 4f;
public float ScrollSensitivity = 2f;
public float OrbitSpeed = 10f;
public float ScrollSpeed = 6f;
public bool CameraDisabled = false;
void Start () {
this.XForm_camera = this.transform;
this.XForm_Parent = this.transform.parent;
}
// Update is called once per frame
void LateUpdate () {
if (Input.GetKeyDown(KeyCode.LeftShift))
{
CameraDisabled = !CameraDisabled;
}
if (!CameraDisabled)
{
if(Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0)
{
LocalRotation.x += Input.GetAxis("Mouse X") * MouseSensitivity;
LocalRotation.y -= Input.GetAxis("Mouse Y") * MouseSensitivity;
LocalRotation.y = Mathf.Clamp(LocalRotation.y, 0f, 90f);
}
if(Input.GetAxis("Mouse ScrollWheel") != 0f)
{
float ScrollAmount = Input.GetAxis("Mouse ScrollWheel") *
ScrollSensitivity;
ScrollAmount *= (this.CameraDistance * 0.3f);
this.CameraDistance += ScrollAmount * -1f;
this.CameraDistance = Mathf.Clamp(this.CameraDistance, 1.5f, 100f);
}
}
Quaternion QT = Quaternion.Euler(LocalRotation.y, LocalRotation.x, 0);
this.XForm_Parent.rotation = Quaternion.Lerp(this.XForm_Parent.rotation, QT, Time.deltaTime * OrbitSpeed);
if (this.XForm_camera.localPosition.z != this.CameraDistance * -1f)
{
this.XForm_camera.localPosition = new Vector3(0f, 0f, Mathf.Lerp(this.XForm_camera.localPosition.z, this.CameraDistance * -1f, Time.deltaTime * ScrollSpeed));
}
}
}
Я получаю ссылку на объект, не установленную для экземпляра ошибки объекта.Я получаю эту ошибку в строке "this.XForm_Parent.rotation = Quaternion.Lerp (this.XForm_Parent.rotation, QT, Time.deltaTime * OrbitSpeed);".Надеюсь, что кто-то может помочь мне бороться с этим долгое время.