Reputation: 196
I´m having trouble using the new action based input system in Unity OpenXR.
I want to update the Animator objects with the values of the ActionBasedController
. In general this works but only delivers 0 or 1. This way the animation looks simple. I´m looking for a way to read real floats so the animation only changes partially.
This is my code to read the trigger and grip value:
ActionBasedController controller = GetComponent<ActionBasedController>();
handAnimator.SetFloat("Trigger", controller.activateAction.action.ReadValue<float>());
handAnimator.SetFloat("Grip", controller.selectAction.action.ReadValue<float>());
I´ve tried to research about the topic, but I only find answers about the old input system.
Any help or new idesas are greatly appreciated.
In case it´s neede I´m using Unity 2020.3.4f1 and I'm using the OpenXR plugin version 1.0.3.
Upvotes: 2
Views: 2607
Reputation: 111
In your default action inputs you should also have a select action value which returns an axis value. In your code you are accessing the button value here which will give you a 0 or a 1. So if you want the values in between 0 and 1 your code should be:
ActionBasedController controller = GetComponent<ActionBasedController>();
handAnimator.SetFloat("Trigger", controller.activateActionValue.action.ReadValue<float>());
handAnimator.SetFloat("Grip", controller.selectActionValue.action.ReadValue<float>());
Upvotes: 2