using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class ViewpointSwitching : MonoBehaviour {
[SerializeField]
private Vector3[] vecs;
[SerializeField]
private Vector3[] rot;
public Camera camtwo;
public float camSpeed = 2f;
public static int i;
bool s;
private bool _bAdjustableAngle;
private Camera _FristCam;
private bool m_bKeyVisualAngle;
void Start () {
i = 0;
s = false;
_FristCam = GetComponent<Camera>();
}
void Update () {
bool bkey = Lynx_Input.GetKey(KeysSetting.keysvalues.m_visualAngle);
if (!bkey)
{
m_bKeyVisualAngle = true;
}
if (Input.GetKeyDown(KeyCode.Tab) && s == false || (bkey && m_bKeyVisualAngle))
{
m_bKeyVisualAngle = false;
i++;
if (i > vecs.Length - 1) i = 0;
s = true;
ViewpointSw(camSpeed);
}
controlCameramotion();
}
private void ViewpointSw(float j)
{
transform.DOLocalMove(vecs[i], j).OnComplete(() => { s = false; });
transform.DOLocalRotate(rot[i], j);
camtwo.transform.DOLocalMove(vecs[i + 1 >= vecs.Length ? 0 : i + 1], j);
camtwo.transform.DOLocalRotate(rot[i + 1 >= vecs.Length ? 0 : i + 1], j);
}
void controlCameramotion()
{
if (Input.GetKeyDown(KeyCode.M))
{
_bAdjustableAngle = !_bAdjustableAngle;
}
if (_bAdjustableAngle)
{
if (Input.GetKey(KeyCode.LeftArrow) || Lynx_Input.GetKey(KeysSetting.keysvalues.m_Left))
{
_FristCam.transform.Rotate(0, -10f * Time.deltaTime, 0);
}
if (Input.GetKey(KeyCode.RightArrow) || Lynx_Input.GetKey(KeysSetting.keysvalues.m_Right))
{
_FristCam.transform.Rotate(0, 10f * Time.deltaTime, 0);
}
if (Input.GetKey(KeyCode.UpArrow) || Lynx_Input.GetKey(KeysSetting.keysvalues.m_Front))
{
_FristCam.transform.Rotate(-10f * Time.deltaTime, 0, 0);
}
if (Input.GetKey(KeyCode.DownArrow) || Lynx_Input.GetKey(KeysSetting.keysvalues.m_Back))
{
_FristCam.transform.Rotate(10f * Time.deltaTime, 0, 0);
}
}
if (Input.GetKey(KeyCode.B))
{
ViewpointSw(camSpeed);
}
}
}

|