MRTK thumbstick input

混江龙づ霸主 提交于 2019-12-11 04:27:07

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/56019016/mrtk-thumbstick-input

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!