Skip to content

Commit

Permalink
fix(phantom): fix spectate bind logic
Browse files Browse the repository at this point in the history
  • Loading branch information
winstxnhdw committed Feb 12, 2024
1 parent ac6a495 commit 5206b5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lc-hax/Scripts/Components/KeyboardMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion lc-hax/Scripts/Modules/PhantomMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5206b5b

Please sign in to comment.