Creating a laser pointer in Stingray

By
-
Login to Follow
-
Industry
  • Film & VFX
  • Games
  • Design Visualization
Subject
  • Foundation
  • General
  • Basics
  • Creating Effects
  • Simultion and Effects
Products
  • Stingray
Skill Level
  • Beginner
Duration
20 min

You asked for it on the forums, and here it is. Creating a laser pointer for your VR Steam project in Stingray has never been easier. In this tutorial you will learn how to selectively circumvent the Steam VR controller's teleport mechanic in the Steam template and replace it with a laser pointer.

In this tutorial we’ll show you how to create a laser pointer in your VR scene. To follow along, download the required files.

Set up the controller unit

  1. Create a new project based on the Steam VR template.
  2. In the Asset Browser, double-click to open the
    unit vr_steam/models/controller.
  3. In the Script Data panel, add the key “enable_teleport” and set the default value
    to true.
  4. In Flow, add in a Get Unit Bool Data node and a Branch node, connect as below.
  5. Close the Unit Editor.

Disable the default teleport functionality

  1. Open up the level flow of the default level.
  2. Using the globally available variables of the Steam VR template for
    wand_1 and wand_2, we’ll now set the enable_teleport to false and true
    respectively.
  3. Add a Level Loaded and a Delay node and connect to the Set Boolean nodes. Slower computers may require a greater delay amount than .1 but generally, this should be fine.
  4. Set up all of the required files as follows:
    - Copy the Laser Pointer/content/models/laser_pointer folder (found in the project download) to your project/content/models folder.
    - Copy Laser Pointer/script/laser_pointer.script_flow_nodes to your project/script/ folder.
    - Copy LaserPointer/script/lua/laser_pointer.lua to your project/script/lua folder.
  5. In Stingray, open project/scripts/project.lua
  6. and add the line:
    require 'script/lua/laser_pointer.lua
  7. Save and close the file.

Set up the laser pointer functionality

  1. Now we will add in the laser pointer node, the SteamVR Controller Pose node and the Steam VR Button Node and connect as follows.
  2. Add a length value in the laser pointer node.

  3. In the root of your project, locate boot.package and add...
    "content/models/laser_pointer/*"
    ... to load the models/textures for the laser pointer.


  4. (Optional) Using offset, you can adjust the
    starting position of the laser. You can also change the projection type
    to be contact only, laser only, or contact and laser.

    For information on the hit filter or hit types, you
    can consult the Stingray documentation on Raycast. The laser pointer node uses them in the same way.

    You can optionally use your own custom units for the Laser Contact and Laser Unit inputs. Length of the laser unit should be 1 meter for scaling to work properly. Feel free to open the fbx files and experinment.

    Output "hit" fires once whenever a new hit has occurred.
    Output "Not-Hit" fires once whenever the laser pointer is not hitting.
    Output "common out" offers a node pass through.
    Distance / Laser Scale is the distance from the Start Position to the "hit" unit or the length (whichever is shorter)
    Hit Actor returns the Actor hit by the laser.
    Hit Actor ID returns the Actors id hit by the laser.
    Hit Normal returns the normal vector of the the surface where the laser makes contact.
    Hit Normal Rotation returns the normal rotation of the surface where the laser makes contact.
    Hit Position returns the world position of the laser hit location.
    Hit Unit returns the unit hit by the laser.
    Hitting returns true or false depending on whether the laser is contacting a hit actor or not.
    Laser Contact Unit Out passes through the laser contact unit
    Laser Unit Out passes through the Laser Unit

Posted By
Tags
  • Stingray
  • Foundation
  • General
  • Basics
  • Creating Effects
  • Simultion and Effects
3 Comments
To post a comment please login or register
| 2 years ago
Hello! I followed this tutorial, but when i test or run my project i get this error log: Test Engine / Lua: vr_steam/script/lua/steam_vr_flow_callbacks.lua:61: attempt to perform arithmetic on field 'controllerIndex' (a nil value) Error Context ---------------------------------------- Flow callback: SteamVRFlowCallbacks.button_events Lua Callstack ---------------------------------------- [1] vr_steam/script/lua/steam_vr_flow_callbacks.lua:61:in function [2] [C]: in function trigger_level_update [3] core/appkit/lua/level_wrapper.lua:80: in function update [4] core/appkit/lua/app.lua:252: in function update [5] core/appkit/lua/simple_project.lua:362:in function Lua Locals ---------------------------------------- [1] t = table: 000000007EC7D7C0 [3] self = table: 000000007ECCF150, dt = 0.19999983906745911 [4] dt = 0.19999983906745911, managed = table: 000000007EC61588, _ = [Level], level_wrapper = table: 000000007ECCF150 [5] dt = 0.19999983906745911 Editor / General: Testing failed. See logs. Test Engine / Lua: vr_steam/script/lua/steam_vr_flow_callbacks.lua:61: attempt to perform arithmetic on field 'controllerIndex' (a nil value) Error Context ---------------------------------------- Flow callback: SteamVRFlowCallbacks.button_events Lua Callstack ---------------------------------------- [1] vr_steam/script/lua/steam_vr_flow_callbacks.lua:61:in function [2] [C]: in function trigger_level_update [3] core/appkit/lua/level_wrapper.lua:80: in function update [4] core/appkit/lua/app.lua:252: in function update [5] core/appkit/lua/simple_project.lua:362:in function Lua Locals ---------------------------------------- [1] t = table: 000000007EC7D7C0 [3] self = table: 000000007ECCF150, dt = 0.0066666668280959129 [4] dt = 0.0066666668280959129, managed = table: 000000007EC61588, _ = [Level], level_wrapper = table: 000000007ECCF150 [5] dt = 0.0066666668280959129 Editor / General: Testing failed. See logs. localhost / Lua: core/appkit/lua/simple_project.lua:116: Level not loaded content/levels/benzin_apartment_2. Make sure name is correct and the level is referenced by a loaded package. Lua Callstack ---------------------------------------- [1] [C]: in function load_level [2] core/appkit/lua/simple_project.lua:116: in function load_level [3] core/appkit/lua/simple_project.lua:178: in function load_startup_level [4] core/appkit/lua/simple_project.lua:214:in function Lua Locals ---------------------------------------- [2] resource_name = content/levels/benzin_apartment_2, level_name = nil, world = [World] [3] standalone_init_level_name = content/levels/benzin_apartment_2, level_resource_name = content/levels/benzin_apartment_2 [4] config = table: 000000007ECC4E98, world = [World], world_wrapper = table: 000000007ECCE0C0, camera_unit = [Unit 'core/appkit/units/camera/camera'] localhost / Lua: core/appkit/lua/simple_project.lua:116: Level not loaded content/levels/ benzin_apartment_2. Make sure name is correct and the level is referenced by a loaded package. Lua Callstack ---------------------------------------- [1] [C]: in function load_level [2] core/appkit/lua/simple_project.lua:116: in function load_level [3] core/appkit/lua/simple_project.lua:178: in function load_startup_level [4] core/appkit/lua/simple_project.lua:214:in function Lua Locals ---------------------------------------- [2] resource_name = content/levels/ benzin_apartment_2, level_name = nil, world = [World] [3] standalone_init_level_name = content/levels/ benzin_apartment_2, level_resource_name = content/levels/ benzin_apartment_2 [4] config = table: 000000007ECC4E98, world = [World], world_wrapper = table: 000000007ECCE0C0, camera_unit = [Unit 'core/appkit/units/camera/camera'] Test Engine / Lua: vr_steam/script/lua/steam_vr_flow_callbacks.lua:61: attempt to perform arithmetic on field 'controllerIndex' (a nil value) Error Context ---------------------------------------- Flow callback: SteamVRFlowCallbacks.button_events Lua Callstack ---------------------------------------- [1] vr_steam/script/lua/steam_vr_flow_callbacks.lua:61:in function [2] [C]: in function trigger_level_update [3] core/appkit/lua/level_wrapper.lua:80: in function update [4] core/appkit/lua/app.lua:252: in function update [5] core/appkit/lua/simple_project.lua:362:in function Lua Locals ---------------------------------------- [1] t = table: 000000007EC7D7C0 [3] self = table: 000000007ECCF158, dt = 0.0066666668280959129 [4] dt = 0.0066666668280959129, managed = table: 000000007EC61588, _ = [Level], level_wrapper = table: 000000007ECCF158 [5] dt = 0.0066666668280959129 Editor / General: Testing failed. See logs. Any idea how to fix this?
| 2 years ago
Sounds like you are not feeding in the controller index to the steam scripts. Make sure your variables are set properly and that the proper values are being fed. If you want to we can continue this thread on the forums where you can post some images of your flow setup so i can more easily diagnose what is going wrong.
| 2 years ago
Hi, Great tutorial but the project files are no longer available is there another way to get them? Thanks, Tom
*Save $66 per month on Autodesk's Suggested Retail Price (SRP) when purchasing 1 year term 3ds Max or Maya subscription.