Modify OVRPointerVisualizer to only be visible when colliding with selectable objects — Oculus
Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Modify OVRPointerVisualizer to only be visible when colliding with selectable objects

guidewireguidewire Posts: 4
NerveGear
I don't really understand how OVRInputModule is handling the raycasts, but I just want the pointer to appear when I'm pointing at what I want to interact with.

I feel like I should be able to do something like the following, but I'm not getting anything happening. I'm sure what I should be exactly searching for in , but it seems like something that should be more commonplace.

 void Update() {
            activeController = OVRInputHelpers.GetControllerForButton( OVRInput.Button.PrimaryIndexTrigger, activeController);
            Ray selectionRay = OVRInputHelpers.GetSelectionRay( activeController, trackingSpace);

            RaycastHit hit; 
            if (Physics.Raycast(selectionRay, out hit))
            {
                print("hit");
            }

            //if(selectionRay)
            SetPointerVisibility();
            SetPointer(selectionRay);
        }

Tagged:

Comments

  • Geist2501Geist2501 Posts: 21
    Brain Burst
    So i haven't looked at it in detail yet but i can give you two hints without doing so:

    if(selectionRay) //this will always return true, since you set the Ray before
    i know you commented it out, but i guess you either want to check for if(selectionHit != null)
    or better
    move the SetVisibility stuff into the brackets of the raycast check:
    if (Physics.Raycast(selectionRay, out hit))
    {
    SetPointerVisibility();//does that take a bool? if so set it to true SetPointer(selectionRay);

    #if UNITY_EDITOR
      print("hit");//it's good use debug logs with
    #if UNITY_EDITOR
     
    #endif
    }
    Maybe you want to check the RascastHit, before setting anything or use a layerMask.
    I think actually, you might profit from just making your own visualization bit that you have a 100% control over and that fits your game's aesthetics.

    I don't know about your experience so if i say obvious things you did different for reasons i can't see, i apologize.

    hope you got something out of it



  • guidewireguidewire Posts: 4
    NerveGear
    Obviously I was in mid exploration of getting it to work.  I finally got something close to I want doing this instead.
    void Update() {
                activeController = OVRInputHelpers.GetControllerForButton( OVRInput.Button.PrimaryIndexTrigger, activeController);
                Ray selectionRay = OVRInputHelpers.GetSelectionRay( activeController, trackingSpace);
    
                RaycastHit hit;
                //print("hit");
    
                if (Physics.Raycast(selectionRay, out hit, 500f, mask ))
                {
                    if(hit.collider != null)
                    {
                        print("hit " + hit.collider.name);
                        linePointer.enabled = true;
                        gazePointer.gameObject.SetActive(true);
                        //SetPointer(selectionRay, hit);
                    }
                } else
                {
                    linePointer.enabled = false;
                    gazePointer.gameObject.SetActive(false);
                }
    
    
                //if(selectionRay)
                //SetPointerVisibility();
                //SetPointer(selectionRay);
                SetPointer(selectionRay, hit);
            }

Sign In or Register to comment.