Fix player jitter on moving platforms

This commit is contained in:
2026-03-17 22:28:39 +01:00
parent 0355b049ff
commit 758a1d420c
22 changed files with 2351 additions and 603 deletions

View File

@@ -1,6 +1,7 @@
using UnityEngine;
using UnityEngine.InputSystem;
[DefaultExecutionOrder(1001)]
public class CameraThirdPerson : MonoBehaviour
{
[System.Serializable]
@@ -39,6 +40,7 @@ public class CameraThirdPerson : MonoBehaviour
public class References
{
public InputActionAsset InputActions;
public Transform Target;
}
[SerializeField]
@@ -96,7 +98,7 @@ public class CameraThirdPerson : MonoBehaviour
private void SetCursor()
{
bool lockCursor = Player.Owner && !Player.Owner.State.IsPaused;
bool lockCursor = Player.Instance && !Player.Instance.State.IsPaused;
Cursor.lockState = lockCursor ? CursorLockMode.Locked : CursorLockMode.None;
Cursor.visible = !lockCursor;
@@ -104,7 +106,7 @@ public class CameraThirdPerson : MonoBehaviour
private void SetYawAndPitch(float deltaTime)
{
if (!Player.Owner || Player.Owner.State.IsPaused)
if ((!Player.Instance || Player.Instance.State.IsPaused) && !_references.Target)
return;
Vector2 lookInput = _lookAction?.ReadValue<Vector2>() ?? Vector2.zero;
@@ -132,9 +134,11 @@ public class CameraThirdPerson : MonoBehaviour
{
Vector3 offset = Vector3.up * _settings.VerticalOffset;
if (!Player.Owner)
return Vector3.zero + offset;
if (_references.Target)
return _references.Target.position + offset;
else if(Player.Instance)
return Player.Instance.transform.position + offset;
return Player.Owner.transform.position + offset;
return Vector3.zero + offset;
}
}