NON906 / HandMR

スマホVR(cardboard)・だんグラ上で、ハンドトラッキングを行うためのUnityアセット
Other
23 stars 1 forks source link

Error while reading the input #6

Open rahull1616dass opened 1 year ago

rahull1616dass commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.