Open K-Kirsch opened 2 years ago
Hi,
I also had the same problem with the Action Based Controller. However, in this spirit of the original script, I found it easier to replace the XRController with ActionBasedController AbController
and afterwards access the values through the controller. This way the original script stays the same, only replacing the if-Conditions with variable allocation (e.g. gripTarget = abController.selectAction.action.ReadValue<float>();
However, I could not assign the thumb and index touch events, neither in my version not in yours, as apperently the XRI Default Input Actions I am using do not support those. Did you found any solution for that?
Thank you for this! I couldn't get the version above working because of some weird errors I couldn't understand, so I wrote a stripped down version (without lerping) attached below.
As for the thumb and index touch events, the XRI Default Input Actions does not support them but you can add them manually yourself. Just follow the set up detailed in this post here.
For some reason, the triggerTouched binding isn't available from the path menu, but just do as they say in this thread here: "if you select triggerPressed
and then use the blue T button to switch to path mode you can edit the text field and change Pressed to Touched", and it'll work.
Stripped down code:
using UnityEngine;
using UnityEngine.InputSystem;
public class OculusHandAnimation : MonoBehaviour
{
public Animator handAnimator = null;
[Header("Input")]
[SerializeField] public InputActionProperty selectAction;
[SerializeField] public InputActionProperty activateAction;
[SerializeField] public InputActionProperty indexAction;
[SerializeField] public InputActionProperty thumbAction;
private int animLayerIndexThumb = -1;
private int animLayerIndexPoint = -1;
void Start()
{
animLayerIndexPoint = handAnimator.GetLayerIndex("Point Layer");
animLayerIndexThumb = handAnimator.GetLayerIndex("Thumb Layer");
}
void Update()
{
float gripValue = selectAction.action.ReadValue<float>();
handAnimator.SetFloat("Flex", gripValue);
float pinchValue = activateAction.action.ReadValue<float>();
handAnimator.SetFloat("Pinch", pinchValue);
handAnimator.SetLayerWeight(animLayerIndexPoint, 1 - indexAction.action.ReadValue<float>());
handAnimator.SetLayerWeight(animLayerIndexThumb, 1 - thumbAction.action.ReadValue<float>());
}
}
Hi, thanks for the script! I changed it to work with ActionBasedControllers, thought someone else might find this version helpful: