You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			29 lines
		
	
	
		
			712 B
		
	
	
	
		
			C#
		
	
		
		
			
		
	
	
			29 lines
		
	
	
		
			712 B
		
	
	
	
		
			C#
		
	
| 
								 
											1 year ago
										 
									 | 
							
								using Autohand;
							 | 
						||
| 
								 | 
							
								using System.Collections;
							 | 
						||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						||
| 
								 | 
							
								using UnityEngine;
							 | 
						||
| 
								 | 
							
								using UnityEngine.InputSystem;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								public class OpenXRAutoHandAxisFingerBender : MonoBehaviour{
							 | 
						||
| 
								 | 
							
								    public Hand hand;
							 | 
						||
| 
								 | 
							
								    public InputActionProperty bendAction;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    [HideInInspector]
							 | 
						||
| 
								 | 
							
								    public float[] bendOffsets;
							 | 
						||
| 
								 | 
							
								    float lastAxis;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public void OnEnable() {
							 | 
						||
| 
								 | 
							
								        if(bendAction.action != null) bendAction.action.Enable();
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    void LateUpdate()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        var currAxis = bendAction.action.ReadValue<float>();
							 | 
						||
| 
								 | 
							
								        for (int i = 0; i < bendOffsets.Length; i++)
							 | 
						||
| 
								 | 
							
								        {
							 | 
						||
| 
								 | 
							
								            hand.fingers[i].bendOffset += (currAxis - lastAxis) * bendOffsets[i];
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        lastAxis = currAxis;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |