qweere9901
Умник
Создал скрипт для отключения камеры при нажатии ESC
PHP:
void Update ()
{
if (Input.GetKeyDown (KeyCode.Escape) & a == 0)
{
pouse_on_off = 1;
}
if (pouse_on_off == 1 || pouse_on_off == 2 || pouse_on_off == 3)
{
Glav_Pers.GetComponent<MouseLook> ().enabled = false;
Camera_glav.GetComponent<MouseLook> ().enabled = false;
}
else
{
Glav_Pers.GetComponent<MouseLook> ().enabled = true;
Camera_glav.GetComponent<MouseLook> ().enabled = true;
}
}
Но отключается только ось X. Никак не могу исправить, помогите.
Вот сам код MouseLook
Вот сам код MouseLook
PHP:
using UnityEngine;
using System.Collections;
[AddComponentMenu("Camera-Control/Mouse Look")]
public class MouseLook : MonoBehaviour
{
public enum RotationAxes
{
MouseXAndY = 0;
MouseX = 1;
MouseY = 2;
}
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;
public float minimumX = -360F;
public float maximumX = 360F;
public float minimumY = -60F;
public float maximumY = 60F;
float rotationY = 0F;
void Update ()
{
if (axes == RotationAxes.MouseXAndY)
{
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.MouseX)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
}
}
void Start ()
{
if (rigidbody)
rigidbody.freezeRotation = true;
}
}
Последнее редактирование модератором:
