# onPointerMove doesnt pick/collide?

**URL:** <https://forum.babylonjs.com/t/onpointermove-doesnt-pick-collide/10491>\
**Category:** Questions\
**Created:** [May 2, 2020, 12:49pm UTC](https://forum.babylonjs.com/t/onpointermove-doesnt-pick-collide/10491 "2020-05-02T12:49:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MouseOverYou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mouseoveryou/32/2958_2.png) [@MouseOverYou](https://forum.babylonjs.com/u/MouseOverYou)\
**Post date:** [May 2, 2020, 12:49pm UTC](https://forum.babylonjs.com/t/onpointermove-doesnt-pick-collide/10491/1 "2020-05-02T12:49:59Z")

</div>

Hi!

There is this classic PG where you place stuff by scene.onPointerDown on top of a plane:  
[https://www.babylonjs-playground.com/index.html#17QBL9#6](https://www.babylonjs-playground.com/index.html#17QBL9#6)

if I change it to onPointerMove, i was expecting to move the thing around the plane, but is not workng.  
the event gets triggered but it doesnt pick the mesh, see:  
[https://www.babylonjs-playground.com/index.html#17QBL9#7](https://www.babylonjs-playground.com/index.html#17QBL9#7)

any idea why?

thanks for the help!

---

<div class="post-metadata">

**Author:** ![wulf11](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wulf11/32/2196_2.png) [@wulf11](https://forum.babylonjs.com/u/wulf11)\
**Post date:** [May 2, 2020, 3:17pm UTC](https://forum.babylonjs.com/t/onpointermove-doesnt-pick-collide/10491/2 "2020-05-02T15:17:37Z")

</div>

Hi! I am not fully sure why this happens, but I think that you need to launch a ray manually in the onPointerMove callback like that:

```
 scene.onPointerMove = function (evt, pickResult) {
        console.log("moving")
        console.log(pickResult.hit)
        var pickResult = scene.pick(scene.pointerX, scene.pointerY);

        // if the click hits the ground object, we change the impact position
        if (pickResult.hit) {
            impact.position.x = pickResult.pickedPoint.x;
            impact.position.y = pickResult.pickedPoint.y;
        } else {
			
		}
    };

```

This will cause some lags though. Maybe only a PointerDown-event will use the scene.pick() in the background and PointerMove does not 🤔

---

<div class="post-metadata">

**Author:** ![MouseOverYou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mouseoveryou/32/2958_2.png) [@MouseOverYou](https://forum.babylonjs.com/u/MouseOverYou)\
**Post date:** [May 3, 2020, 6:24am UTC](https://forum.babylonjs.com/t/onpointermove-doesnt-pick-collide/10491/3 "2020-05-03T06:24:49Z")

</div>

thats probably it…then the documentation needs an update 🙂 according to the documentation…both pointermove and pointer down should work the same

---

<div class="post-metadata">

**Author:** ![wulf11](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wulf11/32/2196_2.png) [@wulf11](https://forum.babylonjs.com/u/wulf11)\
**Post date:** [May 3, 2020, 6:05pm UTC](https://forum.babylonjs.com/t/onpointermove-doesnt-pick-collide/10491/4 "2020-05-03T18:05:25Z")

</div>

Hmm not quite sure, but you are right the doc does not mention this one…

guess we need to study the _ **InputManager** _ to make sure what happens

> <https://github.com/BabylonJS/Babylon.js/blob/master/src/Inputs/scene.inputManager.ts>

---

<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:** [May 4, 2020, 3:37pm UTC](https://forum.babylonjs.com/t/onpointermove-doesnt-pick-collide/10491/5 "2020-05-04T15:37:38Z")

</div>

Actually this is because casting a ray on each move can be expensive. So you need to turn it on with:

```auto
wall.enablePointerMoveEvents = true;

```

[https://www.babylonjs-playground.com/index.html#17QBL9#8](https://www.babylonjs-playground.com/index.html#17QBL9#8)
