62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
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;
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
}
|
|
|
|
|
|
}
|