msny Posted April 3, 2017 Share Posted April 3, 2017 I'm trying to attach the ray I put in my scene to my active camera so I can move around the camera and have the ray hit whatever my camera is looking at. I've been able to get the ray into my scene, and have it hit something, but haven't been able to figure out how to attach it to my camera so it follows it. My best attempt was trying to create a box, attach it my camera as it's parent and then attach the ray to that box using rayhelper.attachtomesh but my ray is no longer visible when doing this. Any help please. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 3, 2017 Share Posted April 3, 2017 Hello can you provide a repro in the playground? Quote Link to comment Share on other sites More sharing options...
msny Posted April 3, 2017 Author Share Posted April 3, 2017 http://www.babylonjs-playground.com/#KNE0O#24 I modified the sample ray scene to with a webVR free camera instead of the arc camera. In it you can see the ray line in white. Move the camera by clicking the screen and panning. I would like to be able to attach the ray to this camera and have it point wherever I'm looking. Quote Link to comment Share on other sites More sharing options...
Raggar Posted April 3, 2017 Share Posted April 3, 2017 Would it be possible to instead use scene.pick()? I'm not sure if the rayHelper can be used with that function, but it (projects?) a ray from the camera. http://www.babylonjs-playground.com/#KNE0O#25 Check the console and aim for the box or the ground plane. Edit: Oh, I missed the fact that you wanted the ray to be visible. Quote Link to comment Share on other sites More sharing options...
adam Posted April 3, 2017 Share Posted April 3, 2017 It's not visible because the points of the line are on top of each other. Here is an example of using the RayHelper with a camera: http://www.babylonjs-playground.com/#ZHDBJ#39 msny 1 Quote Link to comment Share on other sites More sharing options...
msny Posted April 3, 2017 Author Share Posted April 3, 2017 Thanks adam! was looking for an example like this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.