Project realite virtuel avec C# et Unity using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem;
public class AnimScript : MonoBehaviour { [SerializeField] InputActionReference gripInputAction; [SerializeField] InputActionReference triggerInputAction;
Animator handAnimator;
private void Awake()
{
handAnimator = GetComponent<Animator>();
}
private void OnEnable()
{
gripInputAction.action.performed += GripPressed;
triggerInputAction.action.performed += TriggerPressed;
}
private void OnDisable()
{
gripInputAction.action.performed -= GripPressed;
triggerInputAction.action.performed -= TriggerPressed;
}
private void TriggerPressed(InputAction.CallbackContext obj)
{
handAnimator.SetFloat("Trigger", obj.ReadValue<float>());
}
private void GripPressed(InputAction.CallbackContext obj)
{
handAnimator.SetFloat("Grip", obj.ReadValue<float>());
}
}