This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/Packages/SpaceSkies Free/Demo/Scripts/LookCamera.cs

38 lines
906 B
C#
Raw Permalink Normal View History

2023-04-17 06:22:07 +02:00
using UnityEngine;
using System.Collections;
public class LookCamera : MonoBehaviour
{
public float speedNormal = 10.0f;
public float speedFast = 50.0f;
public float mouseSensitivityX = 5.0f;
public float mouseSensitivityY = 5.0f;
float rotY = 0.0f;
void Start()
{
if (GetComponent<Rigidbody>())
GetComponent<Rigidbody>().freezeRotation = true;
}
void Update()
{
// rotation
if (Input.GetMouseButton(1))
{
float rotX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * mouseSensitivityX;
rotY += Input.GetAxis("Mouse Y") * mouseSensitivityY;
rotY = Mathf.Clamp(rotY, -89.5f, 89.5f);
transform.localEulerAngles = new Vector3(-rotY, rotX, 0.0f);
}
if (Input.GetKey(KeyCode.U))
{
gameObject.transform.localPosition = new Vector3(0.0f, 3500.0f, 0.0f);
}
}
}