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/Scripts/Player/CameraController.cs

61 lines
1.5 KiB
C#
Raw Normal View History

2023-03-14 00:59:59 +01:00
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using UnityEngine;
public class CameraController : MonoBehaviour
{
private float mouseX = 0;
private float mouseY;
[SerializeField]
private Camera cam;
[SerializeField]
private Transform target;
2023-04-08 07:23:11 +02:00
2023-03-14 00:59:59 +01:00
private Vector3 offset;
private Vector3 forward= Vector3.zero;
private Vector3 right = Vector3.zero;
public Vector3 Forward { get { return this.forward; } }
public Vector3 Right { get { return this.right; } }
private float originalDist = 0;
private float newDist = 0;
[SerializeField]
private bool isChild = false;
2023-04-08 07:23:11 +02:00
2023-03-14 00:59:59 +01:00
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
GetMouseLook();
//if(target!=null&&!isChild)
//transform.position = target.transform.position+offset;
forward = new Vector3(cam.transform.forward.x, target.transform.forward.y, cam.transform.forward.z);
right = new Vector3(cam.transform.right.x, target.transform.right.y, cam.transform.right.z);
}
private void GetMouseLook()
{
//mouseX = Input.GetAxis("Mouse X");
//mouseY = Input.GetAxis("Mouse Y");
//transform.Rotate(0, mouseX * Time.deltaTime * 180f, 0);
//cam.transform.parent.parent.transform.Rotate(mouseY * Time.deltaTime * 180f, 0, 0);
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
}
}