MRTK thumbstick input

2019-08-11 09:06发布

I’ve been trying to figure how to access thumb-stick input from the controller in MRTK.

I’m new to coding and the documentation was just a bit too confusing for me to figure out.

I figured out a pointer click through the onPointerClick methods however I just can’t figure the other inputs.

I’m sure it’s simple, I just need to see an example. Any help is appreciated.

Thanks!

标签: mrtk
1条回答
地球回转人心会变
2楼-- · 2019-08-11 09:27

You can try a script like this:

public class ThumbstickMover : InputSystemGlobalListener, IMixedRealityInputHandler<Vector2>
{
    public MixedRealityInputAction moveAction;
    public float speed = 1.0f;

    public void OnInputChanged(InputEventData<Vector2> eventData)
    {
        if (eventData.MixedRealityInputAction == moveAction)
        {
            Vector3 localDelta = speed * (Vector3)eventData.InputData;
            transform.position = transform.position + transform.rotation * localDelta;
        }
    }
}

For that to work you'll need to set as moveAction an input action that is mapped to one of the thumbsticks. Let me know if you have trouble with that.

查看更多
登录 后发表回答