Update
This commit is contained in:
@@ -92,18 +92,13 @@ namespace OnlyScove.Scripts
|
||||
public override void Spawned()
|
||||
{
|
||||
InitializePlayer();
|
||||
if (Object != null && !Object.HasInputAuthority && Runner.IsClient)
|
||||
{
|
||||
if (Controller != null) Controller.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializePlayer()
|
||||
{
|
||||
if (currentState == null) SwitchState(new PlayerIdleState(this));
|
||||
bool isLocal = (Object != null && Object.HasInputAuthority) || (Runner == null || !Runner.IsRunning);
|
||||
|
||||
bool isOffline = Runner == null || !Runner.IsRunning;
|
||||
if (isOffline || (Object != null && Object.HasInputAuthority))
|
||||
if (isLocal)
|
||||
{
|
||||
Local = this;
|
||||
CameraController cameraController = GameObject.FindAnyObjectByType<CameraController>();
|
||||
@@ -116,6 +111,7 @@ namespace OnlyScove.Scripts
|
||||
|
||||
if (Input != null)
|
||||
{
|
||||
Input.enabled = true; // Ensure local input is enabled
|
||||
Input.OnNextInteractEvent -= Interaction.NextInteract;
|
||||
Input.OnNextInteractEvent += Interaction.NextInteract;
|
||||
Input.OnPreviousInteractEvent -= Interaction.PreviousInteract;
|
||||
@@ -124,6 +120,16 @@ namespace OnlyScove.Scripts
|
||||
|
||||
if (Controller != null) Controller.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable input for proxies to prevent "Input Overlap"
|
||||
if (Input != null) Input.enabled = false;
|
||||
|
||||
// On clients, proxies don't need CharacterController enabled
|
||||
if (Runner != null && Runner.IsClient && Controller != null) Controller.enabled = false;
|
||||
}
|
||||
|
||||
if (currentState == null) SwitchState(new PlayerIdleState(this));
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
@@ -181,6 +187,7 @@ namespace OnlyScove.Scripts
|
||||
IsSprintHeld = UnityEngine.Input.GetKey(KeyCode.LeftShift);
|
||||
}
|
||||
|
||||
// Only run logic if we have Input Authority (Local Player) or State Authority (Server simulating Player)
|
||||
if (!isRunning || (Object != null && Object.IsValid && (Object.HasInputAuthority || Runner.IsServer)))
|
||||
{
|
||||
if (hasControl)
|
||||
@@ -197,11 +204,7 @@ namespace OnlyScove.Scripts
|
||||
bool isRunning = Runner != null && Runner.IsRunning;
|
||||
if (isRunning && Object != null && Object.IsValid && !Object.HasInputAuthority)
|
||||
{
|
||||
// Smooth interpolation for proxies
|
||||
if (Movement.NetworkedPosition != Vector3.zero)
|
||||
{
|
||||
transform.position = Vector3.Lerp(transform.position, Movement.NetworkedPosition, Runner.DeltaTime * 15f);
|
||||
}
|
||||
// Note: We now rely on NetworkTransform component for position syncing
|
||||
UpdateAnimator(Runner.DeltaTime);
|
||||
}
|
||||
else if (!isRunning)
|
||||
|
||||
Reference in New Issue
Block a user