RayCast - Only works with ArcCamera

Hi,

So I am using the following line of code in my app for RayCasting

        var ray = scene.createPickingRay(
            scene.pointerX,
            scene.pointerY,
            new BABYLON.Matrix.Identity(),
            camera
          );
          var hit = scene.pickWithRay(ray);
          if (hit.pickedMesh) {
              console.log("Mesh Picked");
          }

but this is only working in ArcCamera and not in the when camera is FollowCamera and UniversalCamera.

Am I missing something or this is how it is written in the BabylonJS?

regards,
Nipun David

That should not be a problem with any camera. Can you repro in the Playground?

1 Like

Got it working, I don’t know how. :roll_eyes:

@Deltakosh Can we have a look around behavior in follow camera like arc camera when camera has stopped following

Regards,
Nipun David

Still need a repro of the issue :slight_smile:

Phew…!
yeah I was able to reproduce it finally, what I had done is commented the pointer input handler block in which I was using these lines.

// scene.onPointerObservable.add((pointerInfo) => {
    // switch (pointerInfo.type) {
    //     case BABYLON.PointerEventTypes.POINTERDOWN:
            console.log("POINTER DOWN");
               var ray = scene.createPickingRay(
                scene.pointerX,
                scene.pointerY,
                new BABYLON.Matrix.Identity(),
                camera
            );
            var hit = scene.pickWithRay(ray);
            if (hit.pickedMesh) {
                console.log("Mesh Picked");
            }
//         break;
//     }
// });

it was a miss from my end as I am working in React Babylon so I run examples on playground and then code them in my project

regards,
Nipun David

1 Like