made skywalk teleportation istructions flip according to the rotation of the entered player.

This commit is contained in:
2025-09-23 15:16:55 +03:00
parent eadbd139e4
commit a8568685ab
4 changed files with 28 additions and 6 deletions

View File

@@ -1,11 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using Unity.XR.CoreUtils;
using UnityEngine;
public class SpaceEnterCollider : MonoBehaviour
{
public GameObject InstructionText;
private void OnTriggerEnter(Collider other)
{
XROrigin player = other.GetComponent<XROrigin>();
if (player == null) return;
// Get player's Z rotation (in degrees)
float playerZ = player.transform.rotation.eulerAngles.z;
if (Mathf.Approximately(playerZ, 0f))
{
InstructionText.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
//Debug.Log("Instruction text rotation" + InstructionText.transform.rotation);
}
else
{
InstructionText.transform.rotation = Quaternion.Euler(0f, 0f, -180f);
//Debug.Log("Instruction text rotation" + InstructionText.transform.rotation);
}
GravityHandler playerGravity = other.GetComponent<GravityHandler>();
if (playerGravity != null)
{
@@ -16,6 +35,9 @@ public class SpaceEnterCollider : MonoBehaviour
private void OnTriggerExit(Collider other)
{
XROrigin Player = other.GetComponent<XROrigin>();
if (Player == null) return;
GravityHandler playerGravity = other.GetComponent<GravityHandler>();
if (playerGravity != null)
{