finished portal fundimentals
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.XR.CoreUtils;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.LowLevel;
|
||||
@@ -19,6 +20,7 @@ public class Menu : MonoBehaviour
|
||||
public GameObject PlayericonFloor1Parent;
|
||||
public GameObject PlayericonFloor2Parent;
|
||||
|
||||
public XROrigin Player;
|
||||
public InputActionReference openMenuAction;
|
||||
private Canvas canvas;
|
||||
|
||||
@@ -44,22 +46,22 @@ public class Menu : MonoBehaviour
|
||||
canvas.enabled = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ToggleMenu(InputAction.CallbackContext context)
|
||||
{
|
||||
// Match the Y rotation of the MenuRotator to the Camera
|
||||
Vector3 cameraRotation = Camera.transform.eulerAngles;
|
||||
Vector3 menuRotatorRotation = MenuRotator.transform.eulerAngles;
|
||||
// Get the camera's local Y rotation relative to the parent of MenuRotator
|
||||
float relativeYRotation = Camera.transform.localEulerAngles.y;
|
||||
|
||||
// Update only the Y rotation, keep X and Z unchanged
|
||||
menuRotatorRotation.y = cameraRotation.y;
|
||||
MenuRotator.transform.eulerAngles = menuRotatorRotation;
|
||||
// Apply the relative Y rotation to MenuRotator while keeping X and Z unchanged
|
||||
MenuRotator.transform.localEulerAngles = new Vector3(0, relativeYRotation, 0);
|
||||
|
||||
// Set the menu rotator position to that of the camera
|
||||
// Set the menu position to match the camera's position in local space
|
||||
MenuRotator.transform.position = Camera.transform.position;
|
||||
|
||||
// Toggle the menu visibility
|
||||
canvas.enabled = !canvas.enabled;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user