Scene.pickWithRay not returning a value

PG: https://www.babylonjs-playground.com/#K2HQZK#11

I am trying to detect when straight-line connections (to be represented using the Line class) between two spheres are disallowed because they pass through another sphere first. So the bottom-most sphere can see the middle one, but not the top-most, for example. But all I have so far is a bunch of Rays that visibly pass through the sphere meshes, but return no hit. Any ideas?

1 Like

I think that is because the meshes are not created when you fire the rays?

Setting a timeout gets a hit now… but I’m not very experienced with BabylonJS so not entirely sure :slight_smile:

3 Likes

Hi @Natalie_Driscoll and welcome to the community. I am only on mobile so cannot update your playground. Put the following after you change the spheres positions, for 0, 1 and 2

sphere[0].computeWorldMatrix(true);
5 Likes

Hi JohnK.

That did it, thank you so much!

1 Like