Making KeyCodes Equal to Touch Triggers?
Hi, I'm relatively new to C# and I was wondering if there was any way I could do something simple that would make my keycode (spacebar, it activates the lightsaber I have) equal to the grip trigger (the Axis1D.PrimaryIndexTrigger). What I was trying to do was have it so if I pressed the spacebar the lightsaber would turn on, and if I pressed the same button again it would turn off. Basically I don't want to have to rewrite in terms of OVRInput because it is already set the way it is, but I'm not sure how to do this. The lines 53 and 245 are the ones that I am referring to. Thanks in advance! :)
Also: this isn't all my code in case that wasn't obvious... just included the important stuff
/// /// The key for toggling the weapon's active state /// </summary> private KeyCode TOGGLE_KEY_CODE = KeyCode.Space; // key pressed if (Input.GetKeyDown(TOGGLE_KEY_CODE)) { ToggleWeaponOnOff(); }
Answer by rh_galaxy · Sep 10, 2020 at 08:25 PM
In ordinary unity "Project Settings->Input" should be axis 9, after installing the oculus plugin. You could do something like this...
float fLastTrg1;
float fTrg1 = Input.GetAxisRaw("Oculus_CrossPlatform_PrimaryIndexTrigger"); //axis 9
if(fTrg1>0.5 && fLastTrg1<0.5) ToggleWeaponOnOff();
fLastTrg1 = fTrg1;