29 lines
716 B
C#
29 lines
716 B
C#
using Photon.Pun;
|
|
using UnityEngine;
|
|
|
|
namespace BlockSpace.Worlds
|
|
{
|
|
[DisallowMultipleComponent]
|
|
public sealed class FallResetTeleport : MonoBehaviourPunCallbacks
|
|
{
|
|
[SerializeField]
|
|
private float yKillPlane = -2000f;
|
|
|
|
[SerializeField]
|
|
private Vector3 respawnPosition = new Vector3(0f, 5f, 0f);
|
|
|
|
private void Update()
|
|
{
|
|
if (PhotonNetwork.InRoom && PhotonNetwork.LocalPlayer != null)
|
|
{
|
|
Transform localVrTeleportRoot = PlayerTeleportUtil.GetLocalVrTeleportRoot();
|
|
Vector3 obj = ((localVrTeleportRoot != null) ? localVrTeleportRoot.position : base.transform.position);
|
|
if (!(obj.y >= yKillPlane))
|
|
{
|
|
PlayerTeleportUtil.TryTeleportLocalPlayer(respawnPosition);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|