Files
Ultimate-Fishing-Simulator-…/Assets/Scripts/Assembly-CSharp/ECM2/Examples/FirstPerson/FirstPersonCharacter.cs
2026-03-04 09:37:33 +08:00

62 lines
1.1 KiB
C#

using DG.Tweening;
using UnityEngine;
namespace ECM2.Examples.FirstPerson
{
public class FirstPersonCharacter : Character
{
[Tooltip("The first person camera parent.")]
public GameObject cameraParent;
private float _cameraPitch;
public float CameraPitch
{
set
{
_cameraPitch = value;
}
}
public virtual void SetPitchTween(float pitch, float time)
{
DOTween.To(() => _cameraPitch, delegate(float x)
{
_cameraPitch = x;
}, pitch, time);
}
public virtual void AddControlYawInput(float value)
{
if (value != 0f)
{
AddYawInput(value);
}
}
public virtual void AddControlPitchInput(float value, float minPitch = -80f, float maxPitch = 80f)
{
if (value != 0f)
{
_cameraPitch = MathLib.ClampAngle(_cameraPitch + value, minPitch, maxPitch);
}
}
protected virtual void UpdateCameraParentRotation()
{
cameraParent.transform.localRotation = Quaternion.Euler(_cameraPitch, 0f, 0f);
}
protected virtual void LateUpdate()
{
UpdateCameraParentRotation();
}
protected override void Reset()
{
base.Reset();
SetRotationMode(RotationMode.None);
}
}
}