This is a tool I made using the known “universal” axis… or is it axes idk… names from the google doc https://docs.google.com/spreadsheets/d/1_iF0NjJniTnQn-knCjb5nLh6rlLfW_QKM19wtSW_S9w/
It allows you to grab the UdonBehaviour from anywhere in the project & access the controller input variables inside of it!
The tool gets Primary(Left) & Secondary(Right) VR controller inputs for:
Stick / Track Pad Left/Right, Down/Up, Press:
Horizontal_Bool - bool
Horizontal_Axis - axis (-1 to 1)(Left to Right)
Vertical_Bool - bool
Vertical_Axis - axis (-1 to 1)(Down to Up)
Stick_Pad_Bool (when you press it like a button) - bool (the Secondary(RIGHT) controller may NOT currently work for Index controllers so avoid using Secondary(RIGHT) stick/track pad press)
Trigger_Bool - bool
Grip_Bool - bool
Grip_Axis - Axis (0 to 1)
VRCMenu_Bool - bool (VRChat menu button)
The Public Variable names inside of ControllerInputs -> Primary & ControllerInputs -> Secondary can be used in an UdonBehaviour -> GetProgramVariable flow to check LocalPlayer vr controller inputs:
The package Comes with a prefab CIDebugMenu, which is an example in itself of how the ControllerInputs prefab can be used. The CIDebugMenu displays all the variables that are being grabbed by the ControllerInputs -> Primary & Secondary Graphs. Showing you your controller inputs in real time on a UI that moves with your avatars head bone.
This CIDebugMenu prefab isn’t needed for the ControllerInputs prefab to work, its just a debug window for you to use while building things.
The CIDebugMenu prefab loses track of the ControllerInputs_Primary & ControllerInputs_Secondary UdonBehaviour variables when you first drag them into your project, so make sure to drag the ControllerInputs -> Primary / Secondary back into the CIDebugMenu ->-> Primary / Secondary Public Variables in the Inspector window. Should look like this if you do it correctly:
The package also comes with an Example prefab that does a couple things. It watches the Primary(LEFT) controller “Stick_Pad_Bool” variable & toggles the CIDebugMenu(or whatever you put there) off & on when you press it. It also watches the Secondary(RIGHT) controller “Vertical_Axis” variable to see if it goes above 0 & simulates a jump… so right stick/track pad up = jump…
The Example prefab also needs its ControllerInputs_Primary & ControllerInputs_Secondary UdonBehaviour variables dragged back into it in the Inspector the first time. It also needs the CIDebugMenu dragged into the Target variable to know what to turn on & off (you could put anything here & it would toggle its ActiveSelf JUST DONT LEAVE IT AS SELF… or it turns itself off…). Should look like this if you do it right:
Hopefully this can help people come up with their own solutions for getting controller inputs, at least until we hopefully get access to some kind of VRCPlayerAPI things that make this way of doing things obsolete
THINGS TO KEEP IN MIND:
If you set it up correctly it SHOULD track the Primary(Left) Horizontal & Vertical Axis for EVERY controller including keyboard WASD. If its not giving you at least these values, make sure you set it up correctly!
This was tested & made using a quest 2 linked. So it is tracking all inputs for at least those controllers!
Don’t expect to JUST toggle something off and on with one of the bool variables & a unary negate, you have to structure it like the SetActive toggle in the Example prefab, or figure out another solution to simulate a “Button_Press” check!
Secondary(RIGHT) controller Stick_Pad_Bool does not currently work for Index controllers(or shouldn’t at least)… this is if you press the stick or track pad like a button… I would have built it to work but the GetHeadsetID nodes are gone, or at least aren’t useable in the graph based system yet. so avoid using it for now.
To drop your own GetAxis nodes do a node search for “Input” - hit enter - “axis” or “button” depending on the controller input… refer to the google doc at the top if you want to figure that all out yourself!
The Horizontal & Vertical bools work by checking if the axis is == 0, & because unity smooths the release of horizontal & vertical axis there’s like a 50ms delay from when it gets released(from full-tilt) to when it actually switches the bool back to false… this should only matter in very rare cases, BUT the Grip_Bool works the same way, so keep that in mind if in some rare case its causing you issues.
I don’t know where the heck to upload this so I dropped it in a private channel on my discord, hopefully the link works for people. I don’t even think it takes you to the discord, it just starts the download. Let me know if I need to find somewhere else to upload it!
Just drop it in your Project tab in unity
Find the prefabs in “Project > Assets > Controller Inputs”
Drag the prefabs into your Hierarchy
Fix the ControllerInput_Primary/Secondary variables for the CIDebugMenu & Example(& Target for Example)
Test it out!
Let me know if its not tracking certain controller inputs for you & let me know what controllers you’re using!!!
Also let me know if it IS working 100% for you & what controllers you’re using!!!