# RayCast - Only works with ArcCamera

**URL:** <https://forum.babylonjs.com/t/raycast-only-works-with-arccamera/14158>\
**Category:** Feature requests\
**Tags:** documentation\
**Created:** [September 14, 2020, 1:42pm UTC](https://forum.babylonjs.com/t/raycast-only-works-with-arccamera/14158 "2020-09-14T13:42:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nipundavid](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nipundavid/32/8789_2.png) [@nipundavid](https://forum.babylonjs.com/u/nipundavid)\
**Post date:** [September 14, 2020, 1:42pm UTC](https://forum.babylonjs.com/t/raycast-only-works-with-arccamera/14158/1 "2020-09-14T13:42:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [September 14, 2020, 3:10pm UTC](https://forum.babylonjs.com/t/raycast-only-works-with-arccamera/14158/2 "2020-09-14T15:10:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nipundavid](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nipundavid/32/8789_2.png) [@nipundavid](https://forum.babylonjs.com/u/nipundavid)\
**Post date:** [September 15, 2020, 7:04am UTC](https://forum.babylonjs.com/t/raycast-only-works-with-arccamera/14158/3 "2020-09-15T07:04:18Z")

</div>

> [@nipundavid](#):
>
> ```auto
> 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");
> }
> 
> ```

Got it working, I don’t know how. 🙄

---

<div class="post-metadata">

**Author:** ![nipundavid](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nipundavid/32/8789_2.png) [@nipundavid](https://forum.babylonjs.com/u/nipundavid)\
**Post date:** [September 15, 2020, 7:21am UTC](https://forum.babylonjs.com/t/raycast-only-works-with-arccamera/14158/4 "2020-09-15T07:21:09Z")

</div>

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

Regards,  
Nipun David

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [September 15, 2020, 3:49pm UTC](https://forum.babylonjs.com/t/raycast-only-works-with-arccamera/14158/5 "2020-09-15T15:49:50Z")

</div>

Still need a repro of the issue 🙂

---

<div class="post-metadata">

**Author:** ![nipundavid](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nipundavid/32/8789_2.png) [@nipundavid](https://forum.babylonjs.com/u/nipundavid)\
**Post date:** [September 16, 2020, 8:56am UTC](https://forum.babylonjs.com/t/raycast-only-works-with-arccamera/14158/6 "2020-09-16T08:56:09Z")

</div>

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
