Jamie Greunbaum f10f7b6fe7 - Added proper podiums and pedestals to round 2.
- Countries in round 3 are now randomised on load instead of on initialisation.
- View tablet now properly resets position on spawn and despawn.
2026-04-26 15:28:50 -04:00

55 lines
1.3 KiB
C#

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);
}
}