2023-03-14 00:59:59 +01:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
using System.Threading;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2023-04-22 09:18:21 +02:00
|
|
|
|
2023-03-14 00:59:59 +01:00
|
|
|
public class CameraController : MonoBehaviour
|
|
|
|
{
|
|
|
|
|
|
|
|
private float mouseX = 0;
|
|
|
|
private float mouseY;
|
|
|
|
[SerializeField]
|
|
|
|
private Camera cam;
|
2023-05-17 06:15:44 +02:00
|
|
|
|
|
|
|
|
2023-03-14 00:59:59 +01:00
|
|
|
[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-22 09:18:21 +02:00
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
|
2023-04-22 09:18:21 +02:00
|
|
|
//Cursor.visible = false;
|
|
|
|
//Cursor.lockState = CursorLockMode.Locked;
|
2023-03-14 00:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|