Forum Discussion
guidewire
7 years agoMember
Modify OVRPointerVisualizer to only be visible when colliding with selectable objects
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.
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);
}2 Replies
Replies have been turned off for this discussion
- Geist2501ExplorerSo 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 beforei know you commented it out, but i guess you either want to check for if(selectionHit != null)or bettermove 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_EDITORprint("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 - guidewireMemberObviously 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);
}
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 8 months ago
- 10 months ago
- 5 years ago