0% found this document useful (0 votes)
138 views4 pages

The Fundamental Steps of Leap Motion Combination in Your Unity 3D Project - 【126Kr】 PDF

The document discusses integrating the Leap Motion hand tracking device with Unity 3D projects. It explains downloading the Leap Motion SDK and Unity plugin assets. The core assets include a HandController prefab to render hands and communicate with the device. Sample code is provided to select and manipulate color cubes in the scene using hand gestures detected by Leap Motion. Extending this, code enables picking up cubes and moving them around the virtual environment. Virtual reality continues advancing, making hand tracking an important part of immersive VR experiences.

Uploaded by

savisu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
138 views4 pages

The Fundamental Steps of Leap Motion Combination in Your Unity 3D Project - 【126Kr】 PDF

The document discusses integrating the Leap Motion hand tracking device with Unity 3D projects. It explains downloading the Leap Motion SDK and Unity plugin assets. The core assets include a HandController prefab to render hands and communicate with the device. Sample code is provided to select and manipulate color cubes in the scene using hand gestures detected by Leap Motion. Extending this, code enables picking up cubes and moving them around the virtual environment. Virtual reality continues advancing, making hand tracking an important part of immersive VR experiences.

Uploaded by

savisu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

08/09/2016 TheFundamentalStepsofLeapMotionCombinationinYourUnity3DProject126Kr

TheFundamentalStepsofLeapMotionCombinationinYour
Unity3DProject
Datetime:2016082307:06:12Topic:Unity3DShare

LeapMotionhasbeentryingtomakevirtualrealitymoreimmersivethaneverwithanewhandtrackingsystem.
Thefutureofhumancomputerinteractionisabouttoundergoastandardsshift.Eversincethestartofcomputing,
scientistsandappdevelopershavebeenworkingtowardcreating3Denvironments.

Weliveinveryinterestingtimes.Wearegrowingclosertomakingthesesciencefictionideasintosciencefacts.In
reality,wehavealreadydonesotosomeextent.Virtualrealityisagreattopic.OneofthemajortopicswithinVRis
theabilitytointeractwiththedigitalworld.Thisarticlewillconcentrateonthecommunicationoftheuserwiththe
digitalworld,applyingahardwaresensordevelopedbyLeapMotion.

Here,Iwillbeincludinghowtocombine&useLeapMotionhandmotionsensorwithUnity3D.

WhatistheLeapMotionController?
TheLeapMotionControllerfunctionsjustlikemovingyourhand.Itfollowsall10fingersuptoone100thofa
millimeter.It'sdramaticallymoredelicatethanexistingmotioncontroltechnology.Thatishowyoucandrawor
paintminimasterpiecesinsideaoneinchcube.

LeapMotionSetupandUnity3DIntegration
First,youwillneedtodownloadtheSDKforLeapMotion.AfteryoudownloadtheSDK,installtheruntime.The
SDKsupportsavarietyofplatformsandlanguagesthatyoucanlookinto.

AssumingyouhavealreadydownloadedandinstalledUnity5onyourmachine,thenextthingyouwillneedtodo
isgettheLeapMotionUnityCoreAssetsfromtheassetstore.

AfterdownloadingandinstallingtheLeapMotionCorecapitals,wecanbeginwithdevelopingoursimplescene
andlearninghowtocommunicatewiththeassets,extendingthemforourownpurposes.Goaheadandcreatea
newemptyprojectandimporttheLeapMotionCoreAssetsintoyourproject.

LeapMotionCoreAssets
Intheprojectwindow,yourmainfocusshouldbetheLeapMotionfolder.ThefoldersthatincludeOVRarefor
applyingLeapMotionwithaVRheadset.Wewillincludethisinafuturearticle.

Youshouldtaketimeandstudythestructuremoreimportantly,studythecontentofeachfolder.Oneofthe
maincoreassetsthatyouwillwanttobecomefamiliarwithistheHandController.Thisisthecentralbuildingblock
thatenablesyoutocommunicatewiththeLeapMotiondeviceinyourview.Itservesasthesupportpointfor
renderingyourhandsinthescene.

TheHandControllerprefabhastheHandControllerscriptconnected,whichenablesyoutocommunicatewiththe
device.Theadvantageofthisdesignisthatyoucanbuildyourownhandmodelsandusethemwiththecontroller
forvisualdesign,aswellascustomgesturesandmore.

AnotherkeypropertyistheHandMovementsystemvector.Awordofwarninghere,youwillneedtoreadthe
documentationandspecificationsforusingtheproperadjustmentsfortheparticularapplicationthatyouare
workingon.

http://126kr.com/article/5q5nbnu7lg9 1/4
08/09/2016 TheFundamentalStepsofLeapMotionCombinationinYourUnity3DProject126Kr

TheHandMovementsystemvectorisusedtoimprovetherangeofmotionofthehandswithoutincreasingthe
possiblemodelsize.PlacingtheHandControllerobjectisessential.Asstated,thisistheanchorpointforyour
camera,andyourcamerashouldbeinthesameareaastheHandController.

Thefactthatyoucanreallyseeyourhandmovementinthepicturebyitselfisahugeundertakingwiththeassets
thathavebeengiven.Tomakeeverythingmoreinteresting,youwillneedtobeabletocommunicatewiththe
environmentandmodifyandmanipulatestuffwithinthescene.

Forsimplicity,wewillsetthreecubesservingasourcolorpallet.Thefirstwillbered,thesecondwillbeblue,and
thethirdonewillbeorange.(Youcanpickanycolorsyouwant,bytheway.)Weneedtoplacethecubesinaway
thatinteractingwiththemiseasyfortheuser.

Wecanputthecubesinthefollowingorder:

TheCube (0,1,3)
RedCube (3,1,3)
BlueCube (0,1,3)
OrangeCube (3,1,3)
ThenextstepistogeneratethescriptthatwillhelpuscommunicatewiththeCubeGameObjects:

Asyoucansee,thecodeisnotverycomplex,butitdoeshelpusgetwhatwewant.Therearethreepublic
variablesthatareapplied:toidentifywhethertheobjectisselectable,thecolorthattheobjectuses,andthe
selectedcolor.

ThecoreofthelogichappensintheOnTriggerEnterfunction.Wechecktoseeiftheobjectthatinteractedwiththe
Cubeistheindexfinger,thenwechecktonoticeiftheobjectisselectable.Iftheobjectisselectable,wesetthe
selectablecolortothepredefinedcolorcodeandexitthefunction.

ThissamefunctionisalsousedtoimplementtheselectedcolorwiththeCubeGameObject.Forthisspecialcase,
wegettheRendererobjectfromtheCubeandsetthematerialcolortotheselectedcolor.

HowAboutMovinganObject?

http://126kr.com/article/5q5nbnu7lg9 2/4
08/09/2016 TheFundamentalStepsofLeapMotionCombinationinYourUnity3DProject126Kr

Thisisgreat,butwhatifyouwantedtobeabletohavemorecommunicationwithyour3Denvironment.Let'slook
atasimpleexampleyouneedtopickupobjectsandmovethemaroundinthescene.

Inorderforustomakeithappen,weneedtowritemorecode!Extendingourexample,wewillimplementthe
codethatwillenableyoutopickuptheCubeobjectandmoveitaroundintheenvironment.

http://126kr.com/article/5q5nbnu7lg9 3/4
08/09/2016 TheFundamentalStepsofLeapMotionCombinationinYourUnity3DProject126Kr

Virtualrealityhasalwaysbeenoneofthosetopicsintheindustrythatgetsalotofexposureatonce,thencools
down.Thistimearound,thingsareabitdifferent.ThehardwareandsoftwareecosystemthatenablesVRis
becomingmoredemocratized.Thecostofthehardware,eventhoughit'snotcheap,isatapointthatmost
developerscanafford.

ThisallowsthedevelopmentcommunitytoprovidebetterVRexperiencesandentertainment.Theideaof
integratinghandmotionandgestureswithVRappsisamust.

http://126kr.com/article/5q5nbnu7lg9 4/4

You might also like