Touch Camera Control to walk through room?

Hi guys,

I want to make a project like

But I don‘t know how to achieve that kind of camera movement. It‘s important that the user should navigate with simple touches. No „holding“ like with the TouchCamera or VirtualJoystickCamera.

Thanks for any note :wink:

@PolygonalSun is our internal Camera and Input magician. I bet he can help :slight_smile:

PS: Welcome to the community !!!

Thanks Sebavan,

it feels good to return here after four years.
I‘ve switched my job to a „classic“ web-developer but now the 3d-world is returning to me. And it‘s cool to see how babylon has developed over the last years.

1 Like

Ohhhhhh yeahhhh !!! you were on the previous forum !!! Welcome back then :wink:

1 Like

Hey @jellix, so from what I’m seeing in that link, it looks mostly like you should use a FreeCamera as your base and could take advantage of scene.onPointerObservable and using pickedPoint info to figure out where to start moving. The reason I’m suggesting this approach is because movement only happens when you click on a wall, painting, or the floor (all meshes)

The biggest issue with this approach would be making sure that you account for and adjust where your camera is moving. The reason I say this is because the picked point is on the meshes themselves and moving might put you in the wall or in the floor. If you were just to use the X and Y from the picked point, you should be fine:

scene.onPointerObservable((pointerInfo) => {
    if (pointerInfo.type === PointerEventTypes.POINTERPICK) {
        let pick = pointerInfo.pickedInfo.pickedPoint;
        // Put some adjustment for walls, obstacles, and the floor
        // pick will be a Vector3 with the exact point that you clicked

Depending on how you set things up, you could use this value as a key frame for an Animation object with your camera’s position and target (or you could just set the target and just animate the position).

1 Like

Hi PolygonalSun,

great! This is exactly the answer that I hoped for.
I understand your suggestions and also would look for the position of the click-target to move there. To not crash into walls I will set up a sphere around the cam and make it anti-collision. And I think I won‘t let the cam get to the exact target position but will stop „20 centimeters“ before.

So a task for me will be to calculate the distance between the cam and the target (the animation duration should be depending on that) and to calulate a custom camera-target, based on the click-target and the camera origin.

You already helped a lot. Especially with the camera-type.


1 Like