Files
PrinceOfGlory/Assets/__Test/Test/HandPosTest.cs
kridoo 6e91a0c7f0 111
2025-09-15 17:32:08 +08:00

72 lines
1.6 KiB
C#
Raw Blame History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HandPosTest : MonoBehaviour
{
bool isStay = false;
Transform oldTransform;
Rigidbody rigidbody;
bool isTirgger = true;
// Start is called before the first frame update
void Start()
{
oldTransform = this.transform.parent;
rigidbody = this.GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.X))
{
HandExit();
}
}
private void OnTriggerStay(Collider other)
{
if (other.gameObject.name == "PalmBox_L" || other.gameObject.name == "PalmBox_R")
{
if (isTirgger)
{
isTirgger = false;
GameObject obj = other.transform.parent.Find("PalmBox_GD").gameObject;
this.transform.parent = obj.transform;
rigidbody.useGravity = false;
Debug.Log("手了我:" + other.gameObject.name);
}
isStay = true;
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject.name == "PalmBox_L" || other.gameObject.name == "PalmBox_R")
{
isStay = false;
isTirgger = true;
}
}
void HandExit()
{
rigidbody.useGravity = true;
this.transform.parent = oldTransform;
}
//private void OnCollisionStay(Collision collision)
//{
// Debug.Log("˭<><CBAD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"+collision.gameObject.name);
//}
//private void OnCollisionExit(Collision collision)
//{
//}
}