# Move mesh like a camera with attachControl()

**URL:** <https://forum.babylonjs.com/t/move-mesh-like-a-camera-with-attachcontrol/1982>\
**Category:** Questions\
**Created:** [March 19, 2019, 5:30pm UTC](https://forum.babylonjs.com/t/move-mesh-like-a-camera-with-attachcontrol/1982 "2019-03-19T17:30:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sven](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sven/32/1323_2.png) [@Sven](https://forum.babylonjs.com/u/Sven)\
**Post date:** [March 19, 2019, 5:30pm UTC](https://forum.babylonjs.com/t/move-mesh-like-a-camera-with-attachcontrol/1982/1 "2019-03-19T17:30:51Z")

</div>

Hello everyone.

I use `cam.attachControl(canvas, true)` to move my camera with the mouse or fingers and it’s very convenient.  
When I click on a mesh from my scene, I disables the camera control and I would like a similar control to be made to rotate and move my mesh.

This is my actual code :

```auto
myMesh.actionManager.registerAction(
	new BABYLON.ExecuteCodeAction({
			trigger: BABYLON.ActionManager.OnPickTrigger,
		},
		function (event) {
			const pickedMesh = event.meshUnderPointer
			app.$data.opened.scene._activeCamera.inputs.clear()
			console.log(pickedMesh.getPositionExpressedInLocalSpace())
			// how move my mesh with fingers or mouse here ?
		}
	)
)

```

Is there a simple way to do this ?  
I’m starting with Babylon.js and if my code can be simplified, I’d like to know how.  
Thank you 🙂

---

<div class="post-metadata">

**Author:** ![trevordev](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/trevordev/32/16_2.png) [@trevordev](https://forum.babylonjs.com/u/trevordev)\
**Post date:** [March 19, 2019, 7:33pm UTC](https://forum.babylonjs.com/t/move-mesh-like-a-camera-with-attachcontrol/1982/2 "2019-03-19T19:33:24Z")

</div>

Unfortunately, I’m not aware of a way to map the camera input types to the mesh but depending on your goal you could try one of the following:

Listening to key inputs manually to update the mesh: (eg. [https://playground.babylonjs.com/#15EY4F#0](https://playground.babylonjs.com/#15EY4F#0))  
Listen to pointer observables to update the mesh (eg. [https://playground.babylonjs.com/#C245A1#0](https://playground.babylonjs.com/#C245A1#0))  
Using gizmos to manipulate the mesh (eg. [https://playground.babylonjs.com/#8MGKWK#25](https://playground.babylonjs.com/#8MGKWK#25))

For camera’s I’ve often also found that I use an existing camera input type to get started quickly but once I want a bit more custom movement (eg. for a game character or object following) I end up manually controlling a freeCamera.

---

<div class="post-metadata">

**Author:** ![Sven](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sven/32/1323_2.png) [@Sven](https://forum.babylonjs.com/u/Sven)\
**Post date:** [March 19, 2019, 8:21pm UTC](https://forum.babylonjs.com/t/move-mesh-like-a-camera-with-attachcontrol/1982/3 "2019-03-19T20:21:19Z")

</div>

Thank you so much. I will try this 😋
