![[LeapMotion + UniRx] Moving a Camera with Hand Gestures](/_next/image?url=https%3A%2F%2Fmedia2.dev.to%2Fdynamic%2Fimage%2Fwidth%3D800%252Cheight%3D%252Cfit%3Dscale-down%252Cgravity%3Dauto%252Cformat%3Dauto%2Fhttps%253A%252F%252Fdev-to-uploads.s3.amazonaws.com%252Fuploads%252Farticles%252F3p7tqcy9livztdithfy2.png&w=1200&q=75)
[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 Looking Glass, but that's not the focus of this article.) // Detect dark theme var iframe = document.getElementById('tweet-1108794958318702592-826'); 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 : MonoBehaviour
Continue reading on Dev.to
Opens in a new tab




