Files
beyond/Assets/Scripts/InvectorDerivatives/bThirdPersonCamera.cs
2024-11-20 15:21:28 +01:00

49 lines
1.4 KiB
C#

using System;
using Invector.vCamera;
using UnityEngine;
namespace Beyond
{
public class bThirdPersonCamera : vThirdPersonCamera
{
private static bThirdPersonCamera _instance;
public static new bThirdPersonCamera instance
{
get
{
return _instance;
}
}
private void Awake()
{
if (_instance == null)
{
_instance = this;
}
else
{
Debug.LogError("bThirdPartyCamera already exists!");
Destroy(gameObject);
}
//#if !MOBILE_INPUT
// Cursor.lockState = CursorLockMode.Locked;
//#endif
}
public Vector3 GetCameraTargetPosition(bool useDefaultRotation)
{
if (currentTarget)
{
var camDir = (currentState.forward * targetLookAt.forward) + ((currentState.right * currentSwitchRight) * targetLookAt.right);
camDir = camDir.normalized;
var targetPos = new Vector3(currentTarget.position.x, currentTarget.position.y, currentTarget.position.z) + currentTarget.transform.up * offSetPlayerPivot;
current_cPos = targetPos + currentTarget.transform.up * currentHeight;
return current_cPos + (camDir * (distance));
}
else
{
return transform.position;
}
}
}
}