Files
PrinceOfGlory/Assets/代码/Pico交互/HandTakeObj.cs
Sora丶kong 2f0862b382 修复报错
2026-03-03 11:32:30 +08:00

60 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
public class HandTakeObj : MonoBehaviour
{
bool isEnterObj;
Transform goodTran;
public XRNode xrNode = XRNode.LeftHand;
public Transform goodParent;
Good good;
void Update()
{
if (isEnterObj)
{
if (InputDevices.GetDeviceAtXRNode(xrNode).TryGetFeatureValue(CommonUsages.trigger, out float triggerValue))
{
if (triggerValue > 0.6f)
{
goodTran.SetParent(transform);
good.IsJiaohu = true;
}
else
{
goodTran.SetParent(goodParent);
good.IsJiaohu = false;
good.sendGoodPos();
}
}
}
}
private void OnTriggerEnter(Collider other)
{
if (goodTran == null && other.gameObject.layer == 6)
{
// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2>Ҹ<EFBFBD><D2B8><EFBFBD><EFBFBD>壬ֱ<E5A3AC><D6B1>û<EFBFBD>и<EFBFBD><D0B8><EFBFBD><EFBFBD><EFBFBD>Ϊֹ<CEAA><D6B9><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ϲ<CFB2><E3B8B8><EFBFBD><EFBFBD>
goodTran = other.transform;
while (goodTran.parent != goodParent)
{
goodTran = goodTran.parent;
}
good = goodTran.GetComponent<Good>();
isEnterObj = true;
}
}
private void OnTriggerExit(Collider other)
{
if (goodTran != null && other.gameObject.layer == 6)
{
goodTran = null;
isEnterObj = false;
}
}
}