Forum Discussion

Thormj's avatar
Thormj
Explorer
30 days ago
Solved

3D Raycast from hands... where is it coming from?

I have a Unity Mixed Reality project... and added the hands and real hands and that's cool. Tossed in a Zombie so I can try to get him to follow me or I can shoot him (finger gun special).  Now I want to fixup the ray cast from the hands/controllers so I can interact with game objects from afar... but I'm not even sure where that ray is coming from so I can see the script.

My "change" would be to have the ray extend 50m... and return a bunch of "hits" with "target class:"

  1. GameObject, yellow [put an explosion effect on that zombie -- if it's hitting the mesh]
  2. Interactable, a blue disc appears [press trigger to activate object]
  3. something from the 3d depth [depth raycast], an orange disc appears [put bullet hole on that]
  4. a scene object [floor/wall], a green [grounded] disc appears (note that that may not be the final terminus -- if there's "more models" outside the window or wall (or maybe you're picking something on the other side of a table).... [code has to see if you can shoot through it]

All of course, flat against the object, and usable in code (you might be able to fire a laser through the window, but it won't go through a wall; code will see if that works)...

But... I don't know where to look... the ray from the hands does #3... but I don't know where in the Asset Tree it's coming from --it will probably also tell me how to make those discs (is it a Gizmo, or a GameObject?).  I figure I can add #1/2 [from the cubes, but I haven't quite figured them out yet either, and #4 [EnvironmentalRayCast [ERC] but I might have to iterate on that one because I don't see a "give me all the hits" from the ERC). 

Questions:
a) Where is this 3d ray coming from in the asset tree so I can learn?
b) Is there a good way to "scale" the discs so they're "always ~20px dia" no matter how far away they are?
c) It looks like I need to change the shader of my zombie,  but I'm not getting the terminology -- it occludes fine (eventually I want the IRL table to occlude it), but I need to say "oh, user picked the bellybutton -- spawn an explosion effect in his gut..." -- and how do you change shaders anyway?  I can change materials from the editor, but...?

  • It comes from... the [Building Block] Raycast Visualizer -- that's the piece that actually fires the ray and puts the splat on the surface.  The splat is a sprite.

    Now that I've seen it, I've extended it and... it works!  Now to get the rest of it going!

1 Reply

  • It comes from... the [Building Block] Raycast Visualizer -- that's the piece that actually fires the ray and puts the splat on the surface.  The splat is a sprite.

    Now that I've seen it, I've extended it and... it works!  Now to get the rest of it going!

→ Find helpful resources to begin your development journey in Getting Started

→ Get the latest information about HorizonOS development in News & Announcements.

→ Access Start program mentor videos and share knowledge, tutorials, and videos in Community Resources.

→ Get support or provide help in Questions & Discussions.

→ Show off your work in What I’m Building to get feedback and find playtesters.

→ Looking for documentation?  Developer Docs

→ Looking for account support?  Support Center

→ Looking for the previous forum?  Forum Archive

→ Looking to join the Start program? Apply here.

 

Recent Discussions