From bec15a6736cf8e1d3ff356510f735304fba29a8a Mon Sep 17 00:00:00 2001 From: CyanLaser Date: Sat, 23 Jan 2021 21:06:32 -0800 Subject: [PATCH] Added support for VRCPlayerAPI.Immobilize --- CyanEmu/Scripts/CyanEmuPlayerController.cs | 12 ++++++++++++ CyanEmu/Scripts/CyanEmuPlayerManager.cs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CyanEmu/Scripts/CyanEmuPlayerController.cs b/CyanEmu/Scripts/CyanEmuPlayerController.cs index 628ff19..c59166b 100644 --- a/CyanEmu/Scripts/CyanEmuPlayerController.cs +++ b/CyanEmu/Scripts/CyanEmuPlayerController.cs @@ -59,6 +59,7 @@ private enum Stance { private Stance stance_; private bool isDead_; + private bool isImmobile_; private bool isWalking_; private float walkSpeed_ = DEFAULT_WALK_SPEED_; @@ -560,6 +561,11 @@ public void PlayerRevived() isDead_ = false; } + public void Immobilize(bool immobilize) + { + isImmobile_ = immobilize; + } + private void Update() { RotateView(); @@ -599,6 +605,12 @@ private void FixedUpdate() jump_ = false; } + // Immobile does not affect Jump + if (isImmobile_) + { + input = Vector2.zero; + } + // always move along the camera forward as it is the direction that it being aimed at Vector3 desiredMove = transform.forward * input.y * speed.x + transform.right * input.x * speed.y; desiredMove.y = 0; diff --git a/CyanEmu/Scripts/CyanEmuPlayerManager.cs b/CyanEmu/Scripts/CyanEmuPlayerManager.cs index 7391e35..eda8bb1 100644 --- a/CyanEmu/Scripts/CyanEmuPlayerManager.cs +++ b/CyanEmu/Scripts/CyanEmuPlayerManager.cs @@ -153,7 +153,7 @@ public static void Immobilize(VRCPlayerApi player, bool immobilized) throw new Exception("[VRCPlayerAPI.Immobilize] You cannot set remote players Immobilized"); } - // TODO + player.GetPlayerController().Immobilize(immobilized); } public static void TeleportToOrientationLerp(VRCPlayerApi player, Vector3 position, Quaternion rotation, VRC_SceneDescriptor.SpawnOrientation orientation, bool lerp)