wip: PlayerCamera
This commit is contained in:
91
Assets/_Content/Scripts/PlayerCamera.cs
Normal file
91
Assets/_Content/Scripts/PlayerCamera.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class PlayerCamera : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
private class Settings
|
||||
{
|
||||
[Header("Sensivity")]
|
||||
|
||||
[Tooltip("Camera follow smoothness (0 = instant, 1 = smooth)")]
|
||||
[Range(0, 1)]
|
||||
public float FollowSmoothness = .1f;
|
||||
|
||||
[Tooltip("Camera rotation sensitivity")]
|
||||
public float LookSensitivity = 20;
|
||||
|
||||
[Header("Position")]
|
||||
|
||||
[Tooltip("Camera distance from player")]
|
||||
public float Distance = 5;
|
||||
|
||||
[Tooltip("Vertical offset from player")]
|
||||
public float VerticalOffset = 2;
|
||||
|
||||
[Header("Pitch")]
|
||||
|
||||
[Tooltip("Default pitch angle")]
|
||||
public float DefaultPitch = 20;
|
||||
|
||||
[Tooltip("Min pitch angle")]
|
||||
public float MinPitch = -30;
|
||||
|
||||
[Tooltip("Max pitch angle")]
|
||||
public float MaxPitch = 60;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class References
|
||||
{
|
||||
public InputActionAsset InputActions;
|
||||
public Transform Target;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Settings _settings;
|
||||
|
||||
[SerializeField]
|
||||
private References _references;
|
||||
|
||||
private float _yaw;
|
||||
private float _pitch;
|
||||
|
||||
private Vector3 _playerPosition;
|
||||
private InputAction _lookAction;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_lookAction = _references.InputActions.FindActionMap("Player").FindAction("Look");
|
||||
_lookAction?.Enable();
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
_lookAction?.Disable();
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
float t = Time.deltaTime;
|
||||
|
||||
SetCursor();
|
||||
SetYawAndPitch(t);
|
||||
SetPosition();
|
||||
}
|
||||
|
||||
private void SetCursor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void SetYawAndPitch(float deltaTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void SetPosition()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user