# GizmoManager - I can't get the position Gizmo to stick to a targeted mesh

**URL:** <https://forum.babylonjs.com/t/gizmomanager-i-cant-get-the-position-gizmo-to-stick-to-a-targeted-mesh/18167>\
**Category:** Questions\
**Created:** [February 4, 2021, 7:34pm UTC](https://forum.babylonjs.com/t/gizmomanager-i-cant-get-the-position-gizmo-to-stick-to-a-targeted-mesh/18167 "2021-02-04T19:34:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bov/32/14199_2.png) [@Bov](https://forum.babylonjs.com/u/Bov)\
**Post date:** [February 4, 2021, 7:34pm UTC](https://forum.babylonjs.com/t/gizmomanager-i-cant-get-the-position-gizmo-to-stick-to-a-targeted-mesh/18167/1 "2021-02-04T19:34:28Z")

</div>

Hi there, another day of work…one step forward, one back.  
I hope you can help. I’m having a problem with a position gizmo using the gizmo manager [Here is my playground](https://playground.babylonjs.com/#IM9BMN#1). If you click on the upper part, you will see a spherical mesh stick to it. The problem is that the axis arrows aren’t appearing. They used to when the code below was used, but the problem was that the axis arrows appeared on other meshes too. I would like only the top roofTop mesh to have the position Gizmo.

From the [documentation](https://doc.babylonjs.com/divingDeeper/mesh/gizmo), if you use the Gizmo Manager, you can specify what mesh to attach the gizmo to. The nonworking Gizmo code in my playground starts at line 113.

Below - is the old code I had used but was adding the Gizmo to unwanted meshes:

> var gizmoManager = new BABYLON.GizmoManager(scene);  
> gizmoManager.positionGizmoEnabled = true;
> 
> ```
> //*** ENTER (mesh) to attach to model
> gizmoManager.attachToMesh(device);
> 
> ```

---

<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:** [February 4, 2021, 9:45pm UTC](https://forum.babylonjs.com/t/gizmomanager-i-cant-get-the-position-gizmo-to-stick-to-a-targeted-mesh/18167/2 "2021-02-04T21:45:51Z")

</div>

adding @Cedric

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [February 5, 2021, 9:37am UTC](https://forum.babylonjs.com/t/gizmomanager-i-cant-get-the-position-gizmo-to-stick-to-a-targeted-mesh/18167/3 "2021-02-05T09:37:27Z")

</div>

Hi @Bov

You can specify the list of allowed mesh (or nodes) that can be picked with `attachableMeshes` or `attachableNodesSearch `

> **[GizmoManager | Babylon.js Documentation](https://doc.babylonjs.com/typedoc/classes/babylon.gizmomanager#attachablenodes)**
>
> Helps setup gizmo's in the scene to rotate/scale/position nodes \[API\]

You create a gizmo manager with the array of allowed meshes and you are done!

I changed your PG  
[Room with attachments | Babylon.js Playground](https://playground.babylonjs.com/#IM9BMN#2)

see lines 14-16 for gizmomanager creation and line 45 for adding the roomtop meshes to the mesh array.

---

<div class="post-metadata">

**Author:** ![Bov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bov/32/14199_2.png) [@Bov](https://forum.babylonjs.com/u/Bov)\
**Post date:** [February 5, 2021, 11:47am UTC](https://forum.babylonjs.com/t/gizmomanager-i-cant-get-the-position-gizmo-to-stick-to-a-targeted-mesh/18167/4 "2021-02-05T11:47:57Z")

</div>

Hi Cedric, thank you for your response.

This technique using the GizmoManager is interesting and simple to use.

I had a go at using this method. Unfortunately, it was really the green spherical objects (Dev2) that I wanted the gizmo attached to, so I tried attaching the Gizmo to them using your described method. I have the Dev2 objects appearing again in my playground below but using your method the Gizmo isn’t attaching. I obviously must be doing something wrong…do you have any ideas?

[Here is my new playground with the Dev2 objects showing, but no Gizmo](https://playground.babylonjs.com/#IM9BMN#3)

Cheers.

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [February 5, 2021, 12:29pm UTC](https://forum.babylonjs.com/t/gizmomanager-i-cant-get-the-position-gizmo-to-stick-to-a-targeted-mesh/18167/5 "2021-02-05T12:29:21Z")

</div>

You can keep the attachableMeshes for picking but force another to be attached with onPointerUp happens. Only roomtop meshes are selectable but you can move the cloned sphere once 1 is selected.

[Room with attachments - alts | Babylon.js Playground](https://playground.babylonjs.com/#IM9BMN#4)

---

<div class="post-metadata">

**Author:** ![Bov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bov/32/14199_2.png) [@Bov](https://forum.babylonjs.com/u/Bov)\
**Post date:** [February 5, 2021, 1:20pm UTC](https://forum.babylonjs.com/t/gizmomanager-i-cant-get-the-position-gizmo-to-stick-to-a-targeted-mesh/18167/6 "2021-02-05T13:20:23Z")

</div>

Thanks again Cedric. I appreciate your help.

Sorry to be a nuisance…is there a way using this method so that if an earlier sphere is selected again the Gizmo appears? As the spheres may need to be adjusted slightly once placed. The code in my initial post seemed to do this (but was attaching the Gizmo to everything).

Cheers.

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [February 5, 2021, 1:42pm UTC](https://forum.babylonjs.com/t/gizmomanager-i-cant-get-the-position-gizmo-to-stick-to-a-targeted-mesh/18167/7 "2021-02-05T13:42:50Z")

</div>

You can update the attachablemesh array by adding or removing meshes like your cloned spheres.
