Added RocketAssemblyStation and ReadyRocket
This commit is contained in:
@@ -4,6 +4,7 @@ using UnityEngine;
|
||||
public sealed class FirstPersonCameraController : NetworkBehaviour, IPlayerSystem
|
||||
{
|
||||
[SerializeField, Range(1f, 89f)] private float verticalLookLimit = 80f;
|
||||
[SerializeField, Min(0.1f)] private float remotePitchFollowSpeed = 20f;
|
||||
|
||||
private readonly NetworkVariable<float> synchronizedPitch = new(
|
||||
0f,
|
||||
@@ -14,6 +15,7 @@ public sealed class FirstPersonCameraController : NetworkBehaviour, IPlayerSyste
|
||||
private AudioListener audioListener;
|
||||
private MeshRenderer playerRenderer;
|
||||
private float pitch;
|
||||
private float targetPitch;
|
||||
private bool isInitialized;
|
||||
|
||||
public Camera PlayerCamera => playerCamera;
|
||||
@@ -34,7 +36,10 @@ public sealed class FirstPersonCameraController : NetworkBehaviour, IPlayerSyste
|
||||
playerCamera.gameObject.SetActive(isLocalPlayer);
|
||||
|
||||
if (!isLocalPlayer)
|
||||
ApplyCameraPitch(synchronizedPitch.Value);
|
||||
{
|
||||
targetPitch = synchronizedPitch.Value;
|
||||
ApplyCameraPitch(targetPitch);
|
||||
}
|
||||
|
||||
if (!isLocalPlayer)
|
||||
return;
|
||||
@@ -62,7 +67,10 @@ public sealed class FirstPersonCameraController : NetworkBehaviour, IPlayerSyste
|
||||
synchronizedPitch.OnValueChanged += HandleSynchronizedPitchChanged;
|
||||
|
||||
if (isInitialized && !IsOwner)
|
||||
ApplyCameraPitch(synchronizedPitch.Value);
|
||||
{
|
||||
targetPitch = synchronizedPitch.Value;
|
||||
ApplyCameraPitch(targetPitch);
|
||||
}
|
||||
|
||||
if (isInitialized && IsOwner)
|
||||
CaptureCursor();
|
||||
@@ -70,7 +78,17 @@ public sealed class FirstPersonCameraController : NetworkBehaviour, IPlayerSyste
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (!isInitialized || !IsOwner || !Application.isFocused)
|
||||
if (!isInitialized)
|
||||
return;
|
||||
|
||||
if (!IsOwner)
|
||||
{
|
||||
float interpolation = 1f - Mathf.Exp(-remotePitchFollowSpeed * Time.deltaTime);
|
||||
ApplyCameraPitch(Mathf.LerpAngle(pitch, targetPitch, interpolation));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Application.isFocused)
|
||||
return;
|
||||
|
||||
if (Cursor.lockState != CursorLockMode.Locked || Cursor.visible)
|
||||
@@ -89,6 +107,7 @@ public sealed class FirstPersonCameraController : NetworkBehaviour, IPlayerSyste
|
||||
return;
|
||||
|
||||
pitch = Mathf.Clamp(pitch - pitchDelta, -verticalLookLimit, verticalLookLimit);
|
||||
targetPitch = pitch;
|
||||
ApplyCameraPitch(pitch);
|
||||
|
||||
if (IsSpawned)
|
||||
@@ -110,7 +129,7 @@ public sealed class FirstPersonCameraController : NetworkBehaviour, IPlayerSyste
|
||||
private void HandleSynchronizedPitchChanged(float _, float currentPitch)
|
||||
{
|
||||
if (!IsOwner)
|
||||
ApplyCameraPitch(currentPitch);
|
||||
targetPitch = currentPitch;
|
||||
}
|
||||
|
||||
private void ApplyCameraPitch(float currentPitch)
|
||||
|
||||
Reference in New Issue
Block a user