Firstborn/Assets/Scripts/PlayerCameraController.cs
Schaken-Mods 959e80cf72 assets upload
assets upload description.
2023-03-28 12:16:30 -05:00

89 lines
2.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayerCameraController : MonoBehaviour
{
[Header("Camera's")]
[SerializeField] private Transform FPC;
[SerializeField] private Transform TPC;
[Header("Sliders")]
[SerializeField] private Slider TPCADJRotX;
[SerializeField] private Slider TPCADJRotY;
[SerializeField] private Slider TPCADJRotZ;
[SerializeField] private Slider TPCADJPosX;
[SerializeField] private Slider TPCADJPosY;
[SerializeField] private Slider TPCADJPosZ;
[SerializeField] private Slider FPCADJPosX;
[SerializeField] private Slider FPCADJPosY;
[SerializeField] private Slider FPCADJPosZ;
[Header("Information")]
[SerializeField] private Vector3 FPCVectorPos;
[SerializeField] private Vector3 TPCVectorPos;
[SerializeField] private Quaternion TPCVectorRot;
[SerializeField] private bool IsInitializing = false;
void start() {
IsInitializing = true;
FPCVectorPos = FPC.position;
TPCVectorPos = TPC.position;
TPCVectorRot = TPC.rotation;
SetSliders();
}
public void SetSliders() {
IsInitializing = true;
TPCADJRotX.value = TPC.rotation.x;
TPCADJRotY.value = TPC.rotation.y;
TPCADJRotZ.value = TPC.rotation.z;
TPCADJPosX.value = TPC.position.x;
TPCADJPosY.value = TPC.position.y;
TPCADJPosZ.value = TPC.position.z;
FPCADJPosX.value = FPC.position.x;
FPCADJPosY.value = FPC.position.y;
FPCADJPosZ.value = FPC.position.z;
IsInitializing = false;
}
public void ResetThirdPersonCamera() {
TPC.position = TPCVectorPos;
TPC.rotation = TPCVectorRot;
SetSliders();
}
public void ResetFirstPersonCamera() {
FPC.position = FPCVectorPos;
SetSliders();
}
public void UpdateTPCRotation() {
if (IsInitializing == false) {
TPC.rotation = Quaternion.Euler(TPCADJRotX.value, TPCADJRotY.value, TPCADJRotZ.value);
}
}
public void UpdateTPCPosition() {
if (IsInitializing == false) {
Vector3 newTPCPosition = TPC.position;
newTPCPosition.x = TPCADJPosX.value;
newTPCPosition.y = TPCADJPosY.value;
newTPCPosition.z = TPCADJPosZ.value;
TPC.position = newTPCPosition;
}
}
public void UpdateFPCRotation() {
if (IsInitializing == false) {
Vector3 newFPCPosition = FPC.position;
newFPCPosition.x = FPCADJPosX.value;
newFPCPosition.y = FPCADJPosY.value;
newFPCPosition.z = FPCADJPosZ.value;
FPC.position = newFPCPosition;
}
}
}