Files
XMen/Assets/Scripts/TempHand.cs
2025-07-10 14:49:53 +08:00

63 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.Collections;
using System.Collections.Generic;
using DragonLi.Core;
using Mirror;
using Unity.VisualScripting;
using UnityEngine;
public class TempHand : Launcher
{
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("TurretLeft"))
{
Debug.Log("触碰到左手");
EventDispatcher.TriggerEvent("HandLeftTrriger", true);
}
if (other.CompareTag("TurretRight"))
{
Debug.Log("触碰到右手");
EventDispatcher.TriggerEvent("HandRightTrriger", true);
}
}
// <20><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EBBFAA>ǹ̨<C7B9><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χʱ
private void OnTriggerExit(Collider other)
{
if (other.CompareTag("TurretLeft"))
{
EventDispatcher.TriggerEvent("HandLeftTrriger", false);
}
if (other.CompareTag("TurretRight"))
{
EventDispatcher.TriggerEvent("HandRightTrriger", false);
}
}
public new void Update()
{
if (!isOwned)
{
return;
}
if(GameInit.Ins.self==null)
return;
// 左手
if (hand == HandType.Right)
{
// 同步左手位姿
transform.position = GameInit.Ins.self.RightHand.position;
transform.rotation = GameInit.Ins.self.RightHand.rotation;
}
if (hand == HandType.Left)
{
// 同步左手位姿
transform.position = GameInit.Ins.self.LeftHand.position;
transform.rotation = GameInit.Ins.self.LeftHand.rotation;
}
}
}