Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

XRBaseInteractable override problems

Discussion in 'VR' started by steinbrecherandreas, Aug 27, 2020.

  1. steinbrecherandreas

    steinbrecherandreas

    Joined:
    Aug 19, 2020
    Posts:
    5
    I got a problem while following a VR tutorial series. its about climbing on a wall. He overrides the OnSelectEnter and Exit functions. but that isnt working right for me. it is working, but just one time. i couldnt find an answer, so i started playing around why i cant get it right. so i stripped it all down and made a test scene.

    i made a new project and installed the VR dependencies,
    I created a Plane as floor, a sphere and a new vr roomscale rig. this standard one with rayinteractors.
    the sphere has a rigidbody. it has a collider and i added this script to the sphere.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.XR.Interaction.Toolkit;
    5.  
    6.  
    7. public class Test : XRBaseInteractable
    8. {
    9.     protected override void OnSelectEnter(XRBaseInteractor interactor)
    10.     {
    11.         base.OnSelectEnter(interactor);
    12.         Debug.Log("SELECT ENTER");
    13.     }
    14.  
    15.     protected override void OnSelectExit(XRBaseInteractor interactor)
    16.     {
    17.         base.OnSelectExit(interactor);
    18.         Debug.Log("SELECT EXIT");
    19.     }
    20. }
    so shouldnt that setup print "SELECT ENTER" and "SELECT EXIT" to console everytime i press and release the grip button while the rayinteractors point on the sphere? it doesnt for me. it just does it one time. and only for one hand. no matter if i start my test with grabbing with the left or with the right controller.

    1. so... when i use the grip i can SelectEnter it... when i release the grip, i SelectExit it. but thats all. i cant do it a second time.

    if i replace the Test script with a normal XRGrabInteractable, i can take the ball and throw it away as many times i want. so it does the job normally.

    if i use the interactable events for the sphere in the editor its working fine.

    also the haptic events OnSelectEnter and OnSelectExit for the rays are working. just that script does it not right;

    i already tried to use different versions, i completly deinstalled unity and installed it fresh. nothing helps. tried to play with any parameter that could mayby cause that issue. same behavior i get, if i try OnHoverEnter and Exit. guess its with all overriddens.

    hopefully someone can help with that. i cant figure that out. is it a bug? :) the problem is, i finished this tutorial already a few days ago. at this point i didnt pay attention to this part, cause i did not have any problems there. but now i always run into this strange behavior. Is it a strange behavior? or is it something i am missing here? one little checkbox somewhere... i dont know :)

    THX in advance.
     
    Last edited: Aug 27, 2020
  2. steinbrecherandreas

    steinbrecherandreas

    Joined:
    Aug 19, 2020
    Posts:
    5
    aaaarghs ... i found it. it did work all the time. i had the console output set to collabs. so i only saw these 2 events. i didnt see the timestamp change .... damn. a whole day lost for this... but now i have to find another problem why i cant finish that tutorial i was trying ..... *blush.