Fixed player location calculation via camera trigger collider

This commit is contained in:
2025-10-17 17:17:41 +03:00
parent 013ed4944c
commit 2e61259ebe
40 changed files with 7649 additions and 1707 deletions

View File

@@ -0,0 +1,61 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
public class HandPresence : MonoBehaviour
{
public InputDeviceCharacteristics controllerCharacteristics;
private InputDevice targetDevice;
public Animator handAnimator;
void Start()
{
TryInitialize();
}
void TryInitialize()
{
List<InputDevice> devices = new List<InputDevice>();
InputDevices.GetDevicesWithCharacteristics(controllerCharacteristics, devices);
if (devices.Count > 0)
{
targetDevice = devices[0];
}
}
void UpdateHandAnimation()
{
if(targetDevice.TryGetFeatureValue(CommonUsages.trigger, out float triggerValue))
{
handAnimator.SetFloat("Trigger", triggerValue);
}
else
{
handAnimator.SetFloat("Trigger", 0);
}
if (targetDevice.TryGetFeatureValue(CommonUsages.grip, out float gripValue))
{
handAnimator.SetFloat("Grip", gripValue);
}
else
{
handAnimator.SetFloat("Grip", 0);
}
}
// Update is called once per frame
void Update()
{
if(!targetDevice.isValid)
{
TryInitialize();
}
else
{
UpdateHandAnimation();
}
}
}