0
\$\begingroup\$

I have a question regarding Unity VR and Interaction Toolkit.

When I point at a UI canvas element, the raycast turns from red to white (indicating that it is a valid target). However, when I create a plane or terrain, assign a custom layer to it and include the custom layer in the Raycast Mask, the raycast will remain red upon pointing on the plane/terrain (indicating an invalid target).

I don't know how to fix this problem. Any suggestions?

I created an empty plane which the user should be able to teleport on. I assigned the custom layer "test" to it. I have the XR Interaction Toolkit installed. For the right and lefthand controller I added the layer "test" to the Raycast mask (The Layer UI is included there as well, I have no issues with the UI canvas however). When I point at the plane I can teleport successfully, the raycast remains red however, which shouldnt be the case, since the layer "test" is in the Raycast mask.

The issue remains, even when I deactivate my teleportation script!!!! So whenever I point at the plane with the custom layer, the line remains red.

Teleportation:

if (rayInteractor.TryGetCurrent3DRaycastHit(out RaycastHit hit))
{
    if (((currentTeleportationLayer.value & (1 << hit.collider.gameObject.layer)) > 0 ||
         (middleTeleportationLayer.value & (1 << hit.collider.gameObject.layer)) > 0) /* &&
        allowedToMove*/)
    {
        PerformTeleportation(hit.point);
    }
}
rayInteractor.enabled = false;
\$\endgroup\$
3
  • \$\begingroup\$ Can you walk us through the steps to create a Minimal Complete Verifiable Example of this problem in a new, empty project? Once we can see exactly what you're doing, we'll hopefully be able to spot the error. \$\endgroup\$ Commented Dec 11, 2023 at 12:53
  • \$\begingroup\$ Thank you for your reply. I will edit my original post above for more information. \$\endgroup\$ Commented Dec 11, 2023 at 13:34
  • \$\begingroup\$ I think I need to add a Tracked Device Graphic Raycaster component to the plane. I checked the UI canvas and the component is available there??? But I don't think this will solve the invalid color (red) issue. \$\endgroup\$ Commented Dec 11, 2023 at 13:44

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.