Search Unity

Question XRI Ray interactor Attach Transform overrides input rotation

Discussion in 'XR Interaction Toolkit and Input' started by 03gramat, Dec 3, 2022.

  1. 03gramat

    03gramat

    Joined:
    Aug 27, 2012
    Posts:
    3
    Hello,

    I am using an Action Based Controller with a rotation being set as a direction of the expected Ray Interactor.

    I also have a transform being referenced for the Attach Transform of the Ray Interactor. As I understand it, this Attach Transform is used when grabbing an object, so it will be placed in the position and orientation of the Attach Transform if Force Grab is enabled.

    As I am using the Action Based Controller as input for the Ray Interactor, I do not want to specify the Ray Origin transform as this should come from the Input Actions of the Action Based Controller. The reason I don't want to specify the Ray Origin is that I am developing a package to share with other users and do not wish to force users to specify one.

    upload_2022-12-3_20-37-30.png

    The issue I have is that because I have an Attach Transform, my ray is being oriented differently than I expect. I assume it is due to this section of code in the Ray Interactor:

    Code (CSharp):
    1. void CreateRayOrigin()
    2. {
    3.     if (m_RayOriginTransform == null)
    4.     {
    5.         m_RayOriginTransform = new GameObject($"[{gameObject.name}] Ray Origin").transform;
    6.         m_RayOriginTransform.SetParent(transform, false);
    7.         if (attachTransform != null)
    8.         {
    9.             m_RayOriginTransform.position = attachTransform.position;
    10.             m_RayOriginTransform.rotation = attachTransform.rotation;
    11.         }
    12.         else
    13.         {
    14.             m_RayOriginTransform.localPosition = Vector3.zero;
    15.             m_RayOriginTransform.localRotation = Quaternion.identity;
    16.         }
    17.     }
    18. }
    I don't understand why a user would want the above code snippet to occur, as opposed to using the defaulted values (Vector3.zero and Quaternion.identity) as is the case when the Attach Transform is null. Is this an oversight of my use case, or am I misunderstanding the use of Attach Transforms?

    Thanks :)