2023-03-14 00:59:59 +01:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class CameraController : MonoBehaviour
|
|
|
|
{
|
2023-05-18 06:08:40 +02:00
|
|
|
//private float mouseX = 0;
|
|
|
|
//private float mouseY;
|
2023-06-01 17:03:48 +02:00
|
|
|
[SerializeField] private Camera cam;
|
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] private Transform target;
|
2023-05-17 06:15:44 +02:00
|
|
|
|
2023-03-14 00:59:59 +01:00
|
|
|
private Vector3 offset;
|
2023-06-01 17:03:48 +02:00
|
|
|
public Vector3 Forward { get; private set; } = Vector3.zero;
|
2023-03-14 00:59:59 +01:00
|
|
|
|
2023-06-01 17:03:48 +02:00
|
|
|
public Vector3 Right { get; private set; } = Vector3.zero;
|
2023-03-14 00:59:59 +01:00
|
|
|
|
2023-05-18 06:08:40 +02:00
|
|
|
//private float originalDist = 0;
|
|
|
|
//private float newDist = 0;
|
|
|
|
//[SerializeField]
|
2023-06-01 17:03:48 +02:00
|
|
|
// private bool isChild = false;
|
2023-05-12 02:14:49 +02:00
|
|
|
|
2023-04-08 07:23:11 +02:00
|
|
|
|
2023-03-14 00:59:59 +01:00
|
|
|
// Start is called before the first frame update
|
2023-06-01 17:03:48 +02:00
|
|
|
private void Start()
|
2023-03-14 00:59:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
2023-06-01 17:03:48 +02:00
|
|
|
private void Update()
|
2023-03-14 00:59:59 +01:00
|
|
|
{
|
|
|
|
GetMouseLook();
|
|
|
|
//if(target!=null&&!isChild)
|
|
|
|
//transform.position = target.transform.position+offset;
|
2023-06-01 17:03:48 +02:00
|
|
|
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);
|
2023-03-14 00:59:59 +01:00
|
|
|
}
|
2023-06-01 17:03:48 +02:00
|
|
|
|
2023-03-14 00:59:59 +01:00
|
|
|
private void GetMouseLook()
|
|
|
|
{
|
|
|
|
//mouseX = Input.GetAxis("Mouse X");
|
|
|
|
//mouseY = Input.GetAxis("Mouse Y");
|
2023-06-01 17:03:48 +02:00
|
|
|
|
2023-03-14 00:59:59 +01:00
|
|
|
//transform.Rotate(0, mouseX * Time.deltaTime * 180f, 0);
|
|
|
|
//cam.transform.parent.parent.transform.Rotate(mouseY * Time.deltaTime * 180f, 0, 0);
|
|
|
|
|
2023-04-22 09:18:21 +02:00
|
|
|
//Cursor.visible = false;
|
|
|
|
//Cursor.lockState = CursorLockMode.Locked;
|
2023-03-14 00:59:59 +01:00
|
|
|
}
|
2023-06-01 17:03:48 +02:00
|
|
|
}
|