The script WaveVR_Raycast.cs is used to cast a ray from an object like below photo:


This script has the following features:

  1. Creating a LineRenderer: you can see a ray being shown on the screen.
  2. Casting an invisible ray: this feature can be used to detect a 3D or 2D GameObject in world space.

How to use

Add the component WaveVR_Raycast to the object you want to add a ray to:


In editor mode, you can play a scene to see the effect.

Use “right alt + mouse” to controll the rotation.


You can see public variables:

  1. Device Index: The index of the connected device. It is to use with next variable - Listen To Device.
  2. Listen To Device: If checked, the LineRenderer is only generated when a controller with the specified Device Index is connected. Otherwise the LineRenderer is always created.
  3. Add LineRenderer: If unchecked, the LineRender will never be created. This can be unchecked if you do NOT want to use LineRenderer. (e.g. use Mesh)

When a device is connected or disconnected, OnDeviceConnected will enable / disable the LineRenderer.

private void OnDeviceConnected(params object[] args)
    var device = (WVR_DeviceType)args[0];
    var connected = (bool)args[1];

    if (index != device)    // check if the role of connected device is equivalent to developer specified index.
    if (lr != null)
        lr.enabled = connected;