Unity VR: Raycast & Line Visuals
Intro
We are going to make some visual adjustments to the Teleport Interactor to distinguish it from other interactors. Now, these strategies can be applied to any other Interactor but the point of giving the user visuals cues of the different interactions will improve the overall user experience.
Raycast Line Types
These control the shape of the ray used for hit detection — this affects interaction logic (NOT just visuals).
There are three line types:
- Straight Line — Casts a direct line from the interactor forward
- Projectile Curve — Casts an arc-like trajectory affected by gravity
- Bezier Curve — Smooth controllable curve between interactor and target
We will keep the Ray Interactor a straight line and we can set the Teleport Interactor to Projectile Curve it an arc which is a nice visual for the user to show them they will magically jump to that valid Teleport spot.
You may need to mess with the Velocity to get the arc distance the way you want and the Sample Frequency will smooth the line out, but that will be at a performance cost.
Line Colors
Another way to distinguish between the different Interactors is to change the line colors. On the XR Interactor Line Visual, you can control how the line looks based on what the XR Interactor is pointing at.
- Valid Color — Color of the line when pointing at the appropriate interactable target
- Invalid Color — Color of the line when no interactable target is hit
- Blocked Color — Color of the line when the line is obstructed
Reticles
The Reticle and Blocked Reticle are GameObject references that control what visual is shown at the end of your XR Ray (like a cursor or target marker).
- Reticle — When the ray hits a valid target (like a teleport location or interactable object)
- Blocked Reticle — When the ray hits a blocked surface (like a wall or something not teleportable/interactable)
Match Direction Inputs
You might have noticed that the Reticle was pointing in the direction we were facing, but we can fix that by setting any of our Teleportation Areas to Match Direction Input.
You can see now when we rotate the input the Rectile matches the direction, so when we Teleport we will be facing in the direction the Rectile is pointed.
Conclusion
Adding visual cues to your XR Interactors is a simple but effective way to improve user experience and provide clarity on how different interactions work. Adjusting the Raycast Line Type, line colors, and reticle visuals for your Teleport Interactor helps users easily distinguish it from other interactors in your scene.