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()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/_Content/Scripts/PlayerCamera.cs.meta
Normal file
2
Assets/_Content/Scripts/PlayerCamera.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6cb6e5c86d8e1a743824a5571d11cddb
|
||||||
Reference in New Issue
Block a user