Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while reading the input #6

Open
rahull1616dass opened this issue Oct 6, 2022 · 5 comments
Open

Error while reading the input #6

rahull1616dass opened this issue Oct 6, 2022 · 5 comments

Comments

@rahull1616dass
Copy link

Hi, I was trying to read the input of grab interrraction but unfortunalty I am getting this error on logcat

NullReferenceException: Object reference not set to an instance of an object. at HandMR.HandVRSphereHand.get_IsGrab () [0x00000] in <00000000000000000000000000000000>:0 at HandMR.HandVRController.Update () [0x00000] in <00000000000000000000000000000000>:0

used the input system which has came with the package and genarated a c# class to test the input is working or not

I wrote by code like this to do a basic testing.

HandMRXRIDefaultInputActions actionsHand;
private void Awake()
{
    actionsHand = new HandMRXRIDefaultInputActions();
}

private void OnEnable()
{
    actionsHand.Enable();
    actionsHand.XRILeftHand.Select.performed += IsGrabPressed;
}

private void IsGrabPressed(InputAction.CallbackContext context) 
{
    Debug.Log("GrabPressed");
} 

I think from line no. 79 of HandVRSphereHand.cs is causing the issue

Which has this code

public bool IsGrab { get { var gestures = handVRMain_.GetGestures(handVRMain_.GetIdFromHandednesses(ThisEitherHand)); return gestures[(int)HandVRMain.GestureType.Open] < gestures[(int)HandVRMain.GestureType.Close] || gestures[(int)HandVRMain.GestureType.Open] < gestures[(int)HandVRMain.GestureType.Grab]; } }

Please let me know the solution.

@NON906
Copy link
Owner

NON906 commented Oct 7, 2022

Hello,

The current specification works only when Assets/HandMR/Prefabs/HandMRManager.prefab (or HandMRManagerURP.prefab) is placed in the scene.
Please reply if it does not work well even if you place it in.

@rahull1616dass
Copy link
Author

Thank you very much for the quick reply!

Yes the scene has the HandMRManager.prefab. The main issue was related to the HandMR's default input action assets, when I was enabling the actionAsset to use the input events then centerEyeRotation binding was not working. I removed it from action asset now the input asset is working fine.

Also I found few more gestures on the input action, but I could not found on the documentation about how to trigger those. Can you please help me with it?

@NON906
Copy link
Owner

NON906 commented Oct 7, 2022

Also I found few more gestures on the input action, but I could not found on the documentation about how to trigger those. Can you please help me with it?

Only the one with the closest hand shape among them will be true.
(Now that I think about it, "handPose" was more accurate than "gesture".)

@rahull1616dass
Copy link
Author

rahull1616dass commented Oct 7, 2022

Thank you very much for the responce also I would like to know if there any way to detect the hand position on the screen?

Actually we are gonna use the hand to interract with the UI and other 3D objects. So we need to use the raycast to detect the objects or UI elements.

Edit: I just checked the variable DefaultPosition on HandMRManager.cs, is that the position of the hand?

@NON906
Copy link
Owner

NON906 commented Oct 8, 2022

If you're using InputSystem, you can get it with <XRController>{LeftHand}/devicePosition.
Alternatively, you can get HandCenterPosition on HandVRSphereHand.cs.

By the way, DefaultPosition is the default position when the scene starts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants