# Is it possible to \`camera.lockedTarget\` on the mouse pointer when I use the \`Following Camera\`?

**URL:** <https://forum.babylonjs.com/t/is-it-possible-to-camera-lockedtarget-on-the-mouse-pointer-when-i-use-the-following-camera/21818>\
**Category:** Questions\
**Tags:** material\
**Created:** [June 21, 2021, 10:07am UTC](https://forum.babylonjs.com/t/is-it-possible-to-camera-lockedtarget-on-the-mouse-pointer-when-i-use-the-following-camera/21818 "2021-06-21T10:07:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [June 21, 2021, 10:07am UTC](https://forum.babylonjs.com/t/is-it-possible-to-camera-lockedtarget-on-the-mouse-pointer-when-i-use-the-following-camera/21818/1 "2021-06-21T10:07:24Z")

</div>

Hello Everyone

I have some cubes and I want to move the camera like flying through the cubes and following the mouse pointer. I want to know is it possible locked the camera (`camera.lockedTarget`) to follow the mouse pointer ?

here is my PG: [https://playground.babylonjs.com/#DWPQ9R#441](https://playground.babylonjs.com/#DWPQ9R#441)

I use following code but I didn’t any result.

```auto
        scene.onPointerDown = function (evt, result) {
        var pickResult = scene.pick(evt.offsetX, evt.offsetY);
        console.log(pickResult)
        camera.lockedTarget = pickResult.ray.direction;
    }

```

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 21, 2021, 2:52pm UTC](https://forum.babylonjs.com/t/is-it-possible-to-camera-lockedtarget-on-the-mouse-pointer-when-i-use-the-following-camera/21818/2 "2021-06-21T14:52:39Z")

</div>

@Evgeni_Popov could you have a look at this one ? If not I ll do ASAP

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 21, 2021, 3:38pm UTC](https://forum.babylonjs.com/t/is-it-possible-to-camera-lockedtarget-on-the-mouse-pointer-when-i-use-the-following-camera/21818/3 "2021-06-21T15:38:23Z")

</div>

The follow camera only supports [(abstract) meshes as locked target](https://doc.babylonjs.com/typedoc/classes/babylon.followcamera#lockedtarget), not `Vector3`.

You will either have to construct a mesh to set as `lockedTarget` or use another type of camera.

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [June 21, 2021, 3:43pm UTC](https://forum.babylonjs.com/t/is-it-possible-to-camera-lockedtarget-on-the-mouse-pointer-when-i-use-the-following-camera/21818/4 "2021-06-21T15:43:56Z")

</div>

> [@Evgeni\_Popov](#):
>
> (abstract) meshes as locked target

Thank you so much for answering to my question. can I use the Universal Camera to do it?  
or is it possible to construct a small mesh when I click the mouse pointer? I mean when I clicked the mouse where there is no mesh

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 21, 2021, 3:52pm UTC](https://forum.babylonjs.com/t/is-it-possible-to-camera-lockedtarget-on-the-mouse-pointer-when-i-use-the-following-camera/21818/5 "2021-06-21T15:52:48Z")

</div>

Both is possible, you can try both methods.

You can create an abstract mesh just by doing ~~`new BABYLON.AbstrachMesh("name", scene);`~~ `new BABYLON.AbstractMesh("name", scene);`. Then you can set its position.

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [June 21, 2021, 3:53pm UTC](https://forum.babylonjs.com/t/is-it-possible-to-camera-lockedtarget-on-the-mouse-pointer-when-i-use-the-following-camera/21818/6 "2021-06-21T15:53:53Z")

</div>

Thank you so much 🙏 🙏 🙏 🙏

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [June 21, 2021, 4:06pm UTC](https://forum.babylonjs.com/t/is-it-possible-to-camera-lockedtarget-on-the-mouse-pointer-when-i-use-the-following-camera/21818/7 "2021-06-21T16:06:15Z")

</div>

> [@Arash\_Bagheri](#):
>
> `pickResult.ray.direction`

sorry for my question , I use the following code to build small mesh and then set it as a `lockedTarget`:

```
    scene.onPointerDown = function (evt) {
    var pickResult = scene.pick(evt.offsetX, evt.offsetY);
    var impact = new BABYLON.AbstrachMesh("impact", scene)
    impact.material = new BABYLON.StandardMaterial("impactMat", scene);
    impact.material.diffuseColor = new BABYLON.Color3.Red();
    impact.position = pickResult.ray.direction
    camera.lockedTarget = impact
}

```

> **[Babylon.js Playground](https://playground.babylonjs.com/#DWPQ9R%23443)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

but I have an error which said : `BABYLON.AbstrachMesh is not a constructor`

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 21, 2021, 4:16pm UTC](https://forum.babylonjs.com/t/is-it-possible-to-camera-lockedtarget-on-the-mouse-pointer-when-i-use-the-following-camera/21818/8 "2021-06-21T16:16:42Z")

</div>

I spelled it wrongly, it is `AbstractMesh`, not `AbstrachMesh`.

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [June 22, 2021, 5:49am UTC](https://forum.babylonjs.com/t/is-it-possible-to-camera-lockedtarget-on-the-mouse-pointer-when-i-use-the-following-camera/21818/9 "2021-06-22T05:49:46Z")

</div>

Thanks a lot
