Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 1.04 KB

README.md

File metadata and controls

42 lines (34 loc) · 1.04 KB

Project-Virtual-reality

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>());
}

}