Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Minor Bug in XR Ray Interactor?

Discussion in 'AR/VR (XR) Discussion' started by hptware, May 31, 2020.

Thread Status:
Not open for further replies.
  1. hptware

    hptware

    Joined:
    Dec 11, 2012
    Posts:
    107
    Dear All,

    I am using the XR Ray Interactor in sphere cast mode and it is throwing a lot of non-critical error messages from the Physics engine (999+). Its produced in the following code snippet by the sphere cast

    Code (CSharp):
    1.        
    2. int CheckCollidersBetweenPoints(Vector3 from, Vector3 to)
    3.         {
    4.             Array.Clear(m_RaycastHits, 0, kMaxRaycastHits);
    5.  
    6.             if (m_HitDetectionType == HitDetectionType.SphereCast && m_SphereCastRadius > 0.0f)
    7.             {
    8.                 // casts a sphere along a ray from last point to next point to check if there are hits in between
    9.                 return Physics.SphereCastNonAlloc(from, m_SphereCastRadius, [B]to - from[/B],
    10.                     m_RaycastHits, Vector3.Distance(to, from), raycastMask, raycastTriggerInteraction);
    11.             }
    12.             else
    13.             {
    14.                 // raycast from last point to next point to check if there are hits in between                                      
    15.                return Physics.RaycastNonAlloc(from, to - from,
    16.                     m_RaycastHits, Vector3.Distance(to, from), raycastMask, raycastTriggerInteraction);
    17.             }
    18.         }
    It appears to be generated by the direction Vector3 parameter (to-from). The physics engine expects it to be normalised and grumbles when it isnt. It goes away if you normalize the parameter first.

    I've tried editing XRRayInteractor.cs but it keeps changing back on project load. Anyone know how to either: (a) mark an error message so it won't be displayed in the console, or (b) force the change to be preserved in the script? I've only been playing around with the XR for a few days so it is entirely possible there is someway of preventing this I don't know about.
     
  2. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,924
    Log this as a bug if you haven't already (so it gets fixed).

    To modify the source code yourself, google for "edit unity packagemanager source" or similar. There are a couple of options for how you can do this, each with pros and cons - but these are unrelated to VR: they are all features of the Unity Package Manager (and they've been covered a lot by other forum posts in the general forums, and on other websites). I don't have a link off the top of my head or I'd share it, sorry.
     
  3. SLA24

    SLA24

    Joined:
    Oct 15, 2019
    Posts:
    1
    Hi all,

    I am experiencing the same issues when using the sphere cast. I've tried to play around with it a bit but did not manage to normalize the Vector. Can you explain me how to fix this issue within the script? Thanks in advance!

    EDIT: Managed to solve it: (to-from).normalized
     
    Last edited: Oct 19, 2020
  4. Shaunyowns

    Shaunyowns

    Joined:
    Nov 4, 2019
    Posts:
    328
    Will close the thread as you've resolved this!
     
Thread Status:
Not open for further replies.