using UdonSharp; using UnityEngine; using VRC.SDKBase; using VRC.Udon.Common; [UdonBehaviourSyncMode(BehaviourSyncMode.Manual)] public class PlayerPedestal : UdonSharpBehaviour { [SerializeField] private Transform _Pedestal; [SerializeField] private Transform _SpawnPoint; [SerializeField] private GameObject _StandInteract; [UdonSynced] private float _PedestalHeight = 0.0f; private const float MIN_AVATAR_EYE_HEIGHT = 0.745f; public override void OnDeserialization(DeserializationResult result) { _AdjustHeight_Synced(); base.OnDeserialization(result); } public void AdjustHeight(VRCPlayerApi Player) { _PedestalHeight = Player.GetAvatarEyeHeightAsMeters(); _AdjustHeight_Synced(); RequestSerialization(); } private void _AdjustHeight_Synced() { Vector3 ModifiedPosition = _Pedestal.localPosition; ModifiedPosition.y = -Mathf.Clamp( _PedestalHeight, MIN_AVATAR_EYE_HEIGHT, Networking.LocalPlayer.GetAvatarEyeHeightMaximumAsMeters()); _Pedestal.localPosition = ModifiedPosition; } public void EnableStandInteractLocally(bool Enable) { _StandInteract.SetActive(Enable); } public void StandInteract() { AdjustHeight(Networking.LocalPlayer); Networking.LocalPlayer.TeleportTo(_SpawnPoint.position, _SpawnPoint.rotation); } }