| | | 1 | | using System.Collections; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using UnityEngine; |
| | | 4 | | using UnityEngine.XR.Interaction.Toolkit; |
| | | 5 | | |
| | | 6 | | public class Hand_Handler : MonoBehaviour |
| | | 7 | | { |
| | | 8 | | [SerializeField] |
| | 10 | 9 | | private ActionBasedController m_Controller = null; |
| | | 10 | | [SerializeField] |
| | 10 | 11 | | private Animator m_Animator = null; |
| | | 12 | | [SerializeField] |
| | 10 | 13 | | private float m_Speed = 8.0f; |
| | | 14 | | |
| | | 15 | | private const string ANIMATOR_GRIP_PARAM = "Grip"; |
| | | 16 | | |
| | 10 | 17 | | private float m_GripTarget = 0.0f; |
| | 10 | 18 | | private float m_CurGrip = 0.0f; |
| | | 19 | | |
| | | 20 | | |
| | | 21 | | // Update is called once per frame |
| | | 22 | | void Update() |
| | 14410 | 23 | | { |
| | 14410 | 24 | | m_GripTarget = m_Controller.selectAction.action.ReadValue<float>(); |
| | | 25 | | |
| | 14410 | 26 | | if (m_CurGrip != m_GripTarget) |
| | 0 | 27 | | { |
| | 0 | 28 | | m_CurGrip = Mathf.MoveTowards(m_CurGrip, m_GripTarget, Time.deltaTime * m_Speed); |
| | 0 | 29 | | m_Animator.SetFloat(ANIMATOR_GRIP_PARAM, m_CurGrip); |
| | 0 | 30 | | } |
| | 14410 | 31 | | } |
| | | 32 | | } |