From 5206b5b51bd2987cf5ba425e2b59bbd7656254fb Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Mon, 12 Feb 2024 08:42:48 +0800 Subject: [PATCH] fix(phantom): fix spectate bind logic --- lc-hax/Scripts/Components/KeyboardMovement.cs | 2 +- lc-hax/Scripts/Modules/PhantomMod.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lc-hax/Scripts/Components/KeyboardMovement.cs b/lc-hax/Scripts/Components/KeyboardMovement.cs index 0441f7d9..1bf15a95 100644 --- a/lc-hax/Scripts/Components/KeyboardMovement.cs +++ b/lc-hax/Scripts/Components/KeyboardMovement.cs @@ -5,7 +5,7 @@ internal class KeyboardMovement : MonoBehaviour { const float BaseSpeed = 20; float SprintMultiplier { get; set; } = 1; - Vector3 LastPosition { get; set; } + internal Vector3 LastPosition { get; set; } void OnEnable() => this.LastPosition = this.transform.position; diff --git a/lc-hax/Scripts/Modules/PhantomMod.cs b/lc-hax/Scripts/Modules/PhantomMod.cs index 8f14f4c2..45241405 100644 --- a/lc-hax/Scripts/Modules/PhantomMod.cs +++ b/lc-hax/Scripts/Modules/PhantomMod.cs @@ -59,16 +59,18 @@ void Update() { void LookAtPlayer(int indexChange) { if (!Setting.EnablePhantom || Helper.CurrentCamera is not Camera camera) return; + if (!camera.gameObject.TryGetComponent(out KeyboardMovement keyboard)) return; int playerCount = Helper.Players?.Length ?? 0; this.CurrentSpectatorIndex = (this.CurrentSpectatorIndex + indexChange) % playerCount; + if (Helper.GetActivePlayer(this.CurrentSpectatorIndex) is not PlayerControllerB targetPlayer) { this.LookAtNextPlayer(); return; } - camera.transform.position = targetPlayer.playerEye.position; + keyboard.LastPosition = targetPlayer.playerEye.position; } void PhantomEnabled(Camera camera) {