[LeapMotion + UniRx] Moving a Camera with Hand Gestures
Introduction I wanted to find a way to move the Main Camera in Unity when the only available input device was a Leap Motion (no mouse or keyboard). Demo Here's what I built. (The display shown is a...
![[LeapMotion + UniRx] Moving a Camera with Hand Gestures](https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwllu2m8e97e4uisv2213.png)
Source: DEV Community
Introduction I wanted to find a way to move the Main Camera in Unity when the only available input device was a Leap Motion (no mouse or keyboard). Demo Here's what I built. (The display shown is a Looking Glass, but that's not the focus of this article.) // Detect dark theme var iframe = document.getElementById('tweet-1108794958318702592-620'); if (document.body.className.includes('dark-theme')) { iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1108794958318702592&theme=dark" } When your hand is in a fist shape, the camera moves with your hand. When you open your hand, it stops. It feels like 3D mouse dragging — you can also move forward and backward. Sample Code Here's the code. Attach this script to a camera object and it should work. It uses UniRx. using Leap; using System.Collections.Generic; using System.Linq; using UniRx; using UniRx.Triggers; using UnityEngine; /// <summary> /// Camera controller /// </summary> public class CameraController : Mono