Design

Ray casting best practices

Updated: Mar 13, 2026
Focus on creating an ergonomic and responsive experience that minimizes physical fatigue while providing high-confidence targeting logic.

Best practices

Ergonomic neutrality
Prioritize indirect interactions for long-duration tasks to keep users in a neutral body position, which is more comfortable than extended direct interaction.
Multimodal feedback
Deliver multiple forms of feedback. Design visual ray lines, cursors, and effects, and use sound and haptics on controllers to confirm interaction states and improve user confidence.
Targeting disambiguation
Utilize the Interaction SDK's (ISDK) "first/best hover" logic to prioritize intent in scenes containing multiple, closely-packed interactables.
Gesture consistency
Always use the standard pinch gesture for hand-based selections and the trigger for controller-based selection to maintain system-wide familiarity.
Targeting assistance
Implement magnetism and snapping for distant 3D objects (excluding standard 2D UI) to make targeting feel more satisfying and less reliant on pixel-perfect aim.

Dos and don’ts

Below is a list of recommended practices when using ray casting in your immersive experience:
DO Combine ray casting for distant interactions with direct touch and grab interactions to provide a seamless experience.
DON'T Require users to hold their hand in an uncomfortable position for extended periods to maintain a stable ray.
DO Use visuals, audio, and controller-haptic feedback to confirm every targeting and selection event.
DON'T Make interactive elements too small or closely packed, as this can lead to accidental selections when the user is slightly moving while performing a pinch or selection.
DO Use ISDK's "first/best hover" option to prioritize intent in scenes with multiple interactables.
DON'T Introduce long delays in response time that hinder the fluidity of the interaction.
DO For targeting distant virtual objects (not UIs), implement magnetism to make targeting simpler and more satisfying.
DON'T Provide hover effects or interactions for objects that are not in the field of view of the user, occluded, or invisible to the user.
DO Stabilize ray casting by using a secondary body position, like a shoulder or hip point of origin, to stabilize the ray and minimize the impact of natural hand tremors.
DON'T Use the head ray as a primary pointer for users. Utilize standard ray casting instead.
DO Use techniques like filtering rotational noise, casting conical frustums, and snapping to interactables for smoother targeting.

Next steps

Designing experiences

  • Ray casting: Review the usage and anatomy of ray casting interactions.
  • Input mappings: Understand how targeting and selection work across input methods.
  • Comfort: Learn about ergonomic considerations for immersive experiences.

Developing experiences

Meta Spatial SDK

Unity

Unreal

Did you find this page helpful?