40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using UnityEngine;
|
|
|
|
namespace OnlyScove.Scripts
|
|
{
|
|
[System.Serializable]
|
|
public class CameraSideBias
|
|
{
|
|
[Header("Side Bias")]
|
|
[SerializeField] private bool useSideBias = true;
|
|
[SerializeField] private float horizontalBiasAmount = 0.5f;
|
|
[SerializeField] private float biasSmoothTime = 3f;
|
|
|
|
private float _currentSideBias;
|
|
|
|
public float CurrentSideBias => _currentSideBias;
|
|
|
|
public void HandleSideBias(InputReader inputReader)
|
|
{
|
|
float targetBias = 0f;
|
|
|
|
if (SettingsManager.Instance != null && SettingsManager.Instance.Settings != null)
|
|
{
|
|
// Fixed offset based on settings
|
|
targetBias = SettingsManager.Instance.Settings.sideBiasRight ? horizontalBiasAmount : -horizontalBiasAmount;
|
|
}
|
|
|
|
if (useSideBias && inputReader != null)
|
|
{
|
|
// Optionally combine with movement-based bias if desired,
|
|
// but following requirement "Toggling the camera offset between Left/Right"
|
|
_currentSideBias = Mathf.Lerp(_currentSideBias, targetBias, biasSmoothTime * Time.deltaTime);
|
|
}
|
|
else
|
|
{
|
|
_currentSideBias = Mathf.Lerp(_currentSideBias, 0, biasSmoothTime * Time.deltaTime);
|
|
}
|
|
}
|
|
}
|
|
}
|