This repository has been archived on 2026-01-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
AW_2025/Assets/Scripts/SJM/XROrigin_Position.cs
2025-02-24 15:18:12 +09:00

58 lines
1.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
//using UnityEditor.Animations;
using UnityEngine;
using UnityEngine.XR;
public class XROrigin_Position : MonoBehaviour
{
private Player player;
private Transform xrRig;
public Transform body;
public Transform leftHand, rightHand;
public Transform faceUI;
public TMP_Text nameText;
void Start()
{
player = GetComponent<Player>();
xrRig = GameObject.FindWithTag("Player").transform;
nameText.text = gameObject.name;
//for (int i = 1; i <= 6; i++)
//{
// faceUI.transform.GetChild(i).gameObject.SetActive(false);
//}
}
// Update is called once per frame
void Update()
{
if (!player.isDummy)
{
body.gameObject.SetActive(false);
leftHand.gameObject.SetActive(false); // 남한테만 보여야 하고 나한테 안보여야 하기 때문에 나중에 false로 변경
rightHand.gameObject.SetActive(false); // 남한테만 보여야 하고 나한테 안보여야 하기 때문에 나중에 false로 변경
MapPosition(body, XRNode.Head);
MapPosition(leftHand, XRNode.LeftHand); // 자신의 leftHand를 XRNode의 왼손 위치로
MapPosition(rightHand, XRNode.RightHand);
player.OnClick_Button_Send(); // 더미한테 값 보내기
}
}
void MapPosition(Transform target, XRNode node)
{
InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.devicePosition, out Vector3 position);
InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.deviceRotation, out Quaternion rotation);
target.localPosition = position;
target.localRotation = rotation;
target.parent.position = xrRig.transform.position;
target.parent.rotation = xrRig.transform.rotation;
//InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 pos);
}
}