Widget interaction: How do I get which instance of widget interaction clicked a button?
So I am making a menu for our VR toolkit, and in doing so I need to know which hand / vr controller / widget interaction instance clicked the button menu, but I am coming up short in terms of implementation.
The menu shows different tools that can be spawned (measuring tool, painting tool, camera tool) and since people are either left handed or right handed, it would be preferable to spawn the tool in the hand that clicked the button.
I'm currently thinking that the solution lies in giving each widget interaction (hand) a unique pointer index, but I don't understand how to read the pointer index value on the button click event.
Any help would be appreciated, thanks.
Posted Apr 15, 2019, 7:13 AM UTC
So you have a 3d widget in world space that the VR controllers interact with and you want to know which one is the one that sent the interaction, right?
You could override the "on key down" event in the widget, do a "get key" on the in key event, and check what the key is. There's motion controller L&R under gamepad. If there's more than one relevant button that can interact with menus you might need to build a custom function to compare all the various buttons. I don't see a simple "is left/right hand" filter. Not sure if this is the ideal way to do it, or if it'll get what you want. I haven't done much experimenting in VR.
Alternatively, you could do a sort of active/inactive controller and set that each time you press an actual button on the controller in your player character and reference against that whenever the widget event gets triggered.
I was wondering if the "on key down" thing would work but wouldn't it just give you the mouse button, as the interaction component is simulating mouse key press? I could be wrong!
That would be on mouse down, there's a separate event for on key down and you can definitely do gamepads and keyboards.
> So you have a 3d widget in world space that the VR controllers interact with and you want to know which one is the one that sent the interaction, right?
Correct.
This is probably they way I have to go. I was hoping there was some simple way to get information on who or what caused this WidgetButton to trigger OnClick()