Cov txheej txheem:

Augmented Reality App for Beginners: 8 Kauj Ruam
Augmented Reality App for Beginners: 8 Kauj Ruam

Video: Augmented Reality App for Beginners: 8 Kauj Ruam

Video: Augmented Reality App for Beginners: 8 Kauj Ruam
Video: Video Playback Unity 2020 & Vuforia 8 Tutorial in 5 minutes! | Augmented Reality Apps 2024, Hlis ntuj nqeg
Anonim
Augmented Reality App rau Cov Pib
Augmented Reality App rau Cov Pib
Augmented Reality App rau Cov Pib
Augmented Reality App rau Cov Pib

Phau ntawv qhia no yuav qhia koj yuav ua li cas txhawm rau txhim kho app kev muaj tiag rau cov pib tshiab. Peb yuav siv Unity3D thiab Vuforia lub dav hlau hauv av txhawm rau txhawm rau ua tus cim-tsawg AR app rau Android lossis IOS. Peb yuav dhau los ntxiv tus qauv 3D rau Kev Sib Koom thiab txav nws ib puag ncig nrog lub xov tooj ntawm tes. Txoj kev no tseem yuav ua haujlwm nrog lwm cov qauv 3D dawb uas koj tuaj yeem nrhiav tau.

Kauj Ruam 1: Qhov No Puas Ua Haujlwm Hauv Koj Lub Xov Tooj?

Qhov no Puas Ua Haujlwm Ntawm Koj Lub Xov Tooj?
Qhov no Puas Ua Haujlwm Ntawm Koj Lub Xov Tooj?

Ua ntej tshaj plaws peb yuav tsum ua kom ntseeg tau tias koj lub xov tooj txhawb nqa Vuforia lub dav hlau hauv av kom paub tseeb kom ntseeg tau tias koj lub xov tooj nyob hauv cov npe ntawm cov khoom siv txhawb nqa.

library.vuforia.com/articles/Solution/Vufo…

Qhov tsuas yog koj yuav xav tau kom deb li deb tau yog software dawb ntawm Unity. Yog tias koj tsis muaj nws mus rau Unity3d.com thiab nyem tau txais Kev Sib Koom. Tam sim no kuv tab tom siv version 2018.2.0, yog tias cov ntawv no tsis muaj ntxiv mus rau cov ntawv qub ntawm Unity thiab rub tawm 2018.2.0.

Thaum lub sijhawm txheej txheem teeb tsa kom ntseeg tau tias yuav nruab pob khoom rau IOS lossis Android nyob ntawm seb hom xov tooj twg koj muaj thiab nco ntsoov txhim kho Vuforia txhawb nqa.

Kauj Ruam 2: Pib Txoj Haujlwm Kev Sib Koom Tshiab

Pib Txoj Haujlwm Kev Sib Koom Tshiab
Pib Txoj Haujlwm Kev Sib Koom Tshiab

Pib txoj haujlwm Unity tshiab thiab rho tawm lub koob yees duab tseem ceeb. Nyob rau sab saum toj ntawv qhia zaub mov bar mus rau cov khoom ua si, vuforia thiab ntxiv "ARCamera".

Ua ntej txhua yam tuaj yeem ua haujlwm peb xav tau los pab Vuforia yog li mus rau cov ntaub ntawv tsim teeb tsa, hloov chaw, XR teeb tsa, thiab pab kom Vuforia Augmented kev muaj tiag txhawb nqa.

Nyem rau ntawm "ARCamera" cov khoom ua si thiab hauv tus kws tshuaj ntsuam nyem Vuforia teeb tsa. Hauv qab pab cov cuab yeej taug qab thiab hloov hom kev taug qab mus rau qhov chaw.

Ntxiv rau theem dav hlau hauv av thiab lub dav hlau nrhiav los ntawm tib Vuforia cov ntawv qhia uas koj tau txais lub koob yees duab los ntawm.

Ntawm lub dav hlau nrhiav pom hloov cov ntawv qhia zaub mov kom sib tham sib, tshem tawm cov qib sib tshooj, thiab rub cov khoom dav hlau theem hauv av mus rau qhov chaw thauj tog rau nkoj khoob ntawm qhov pom ntawm lub dav hlau nrhiav.

Tam sim no peb xav tau ntxiv peb cov joystick thiaj li nyob rau sab saum toj cov ntawv qhia zaub mov mus rau cov khoom muaj nqis, ntshuam pob, hla lub platform nkag.

Hauv cov txheej txheem ntxiv cov cuab yeej tshiab, mus rau prefab, thiab rub lub xov tooj txawb ib leeg tswj kev ua ntej rau hauv qhov chaw.

Rho tawm khawm dhia. Txoj cai nyem rau hauv lub hierarchy thiab ntxiv UI, txheej xwm txheej xwm.

Thaum kawg ntawm lub joystick hauv paus cov khoom ua si nyem txhawm rau ntxiv ib feem, thiab ntxiv cov canvas scaler. Hloov nws qhov poob qis rau qhov ntsuas nrog qhov loj me. Ntawm Joystick tsab ntawv hloov pauv qhov txav mus rau 25.

Kauj ruam 3: Tsim Toggle

Tsim Toggle
Tsim Toggle

Tam sim no tus cwj pwm tsis zoo ntawm cov ntsiab lus coj tus cwj pwm yog thaum twg peb nyem rau ntawm lub vijtsam hauv av dav hlau theem tau hloov chaw. Qhov no suav nrog thaum peb nyem rau ntawm UI cov khoom zoo li cov nyees khawm lossis joysticks yog li tsis yog qhov peb xav tau. Txij li thaum Vuforia tam sim no tsis tso cai kho cov ntsiab lus tus cwj pwm coj los kho qhov teeb meem no peb tuaj yeem sau peb tus kheej los ntawm kos, lossis rau lub hom phiaj ntawm qhov kev qhia no peb tsuas yog yuav tsim lub toggle uas hloov qhov haujlwm no rau lossis tawm.

Txoj cai nyem rau ntawm tus joystick thiab tsim UI, toggle. Nthuav txhua yam thiab hloov cov xim lossis cov ntawv yog tias koj xav tau.

Ntawm tus nqi hloov pauv ntu ntawm toggle ntxiv lub dav hlau nrhiav thiab ua kom nws teeb tsa cov khoom siv ua si raws li tus nqi ntawm toggle. Tam sim no thaum lub hom phiaj tau muab tso rau hauv ntiaj teb no peb yuav tsum tig lub toggle tawm yog li mus rau cov ntsiab lus tso tus cwj pwm thiab luag hauv qhov toggle mus rau ntawm cov ntsiab lus tso txawm tias thiab teeb lub toggle tawm.

Kauj ruam 4: MONSTER

MONSTER!
MONSTER!

Mus rau lub qhov rais, dav dav, thiab ntxiv qhov khoom vaj khoom tsev qhov rai.

Tshawb nrhiav "tus cwj pwm dab" thiab txheeb cais los ntawm dawb, rub thawj qhov tshwm sim thiab ntshuam tus ntawd.

Luag tus dab prefab hauv qab theem dav hlau hauv av ua rau nws yog menyuam yaus. Teem nws txoj haujlwm thiab kev sib hloov rau xoom. Teem nws x y thiab z nplai rau.1.

Mus rau tus animator thiab rho tawm txhua yam tab sis nkag mus. Luag hauv kev taug kev thiab tsis ua cov duab los ntawm daim nplaub tshev animations ntawm dab.

Hauv ntu ntu nyem rau khawm ntxiv thiab ntxiv ob qhov ua rau "taug kev" thiab "tsis ua haujlwm".

Nyem rau txhua qhov kev ua yeeb yaj kiab thiab ntxiv kev hloov pauv mus rau lwm qhov.

Nyem rau txhua qhov kev hloov pauv thiab ntxiv ib qho xwm txheej, taug kev rau thawj tus thiab tsis ua haujlwm rau qhov thib ob. Uncheck muaj sijhawm tawm thiab rub tag nrho cov swb rau 0 ntawm txhua tus.

Tam sim no peb xav kom txhua qhov ua kom ntxaws yog li nyem rau txhua qhov ua yeeb yaj kiab thiab mus rau nws cov clip. Nyem kho kom raug ntawm txhua tus thiab tshawb xyuas lub sijhawm.

Kauj Ruam 5: Tswj Peb Tus Cwj Pwm

Tswj Peb Tus Cwj Pwm
Tswj Peb Tus Cwj Pwm

Txoj cai nyem rau hauv cov khoom muaj nqis thiab tsim C# tsab ntawv hu ua "CharacterController" thiab ntxiv qhov no:

siv System. Collections;

siv System. Collections. Generic; siv UnityEngine; siv UnityStandardAssets. CrossPlatformInput; pej xeem hauv chav CharacterController: MonoBehaviour {ntiag tus const ntab nrawm =.1f; ntiag tug Animator anim; // Siv qhov no rau qhov pib tsis muaj dab tsi Pib () {anim = GetComponent (); } // Hloov tshiab yog hu ua ib zaug ib kab ntawv tsis muaj dab tsi Hloov tshiab () {// txav tus cim los ntawm joystick cov tswv yim ntab x = CrossPlatformInputManager. GetAxis ("Kab rov tav"); ntab y = CrossPlatformInputManager. GetAxis ("Ntsug"); yog (! x. Equals (0) &&! y. Equals (0)) {transform.eulerAngles = tshiab Vector3 (transform.eulerAngles.x, Mathf. Atan2 (x, y) * Mathf. Rad2Deg, transform.eulerAngles.z); } yog (! x. Equals (0) ||! y. Equals (0)) {transform.position += transform.forward * Time.deltaTime * ceev; anim. SetTrigger ("taug kev"); } lwm tus {anim. SetTrigger ("tsis ua haujlwm"); }} pej xeem tsis muaj chaw PlaceCharacter () {transform.localPosition = Vector3.zero; }}

Kauj Ruam 6: Cia Kuv Piav Qhia

Cia Kuv Piav Qhia
Cia Kuv Piav Qhia

Ua ntej tshaj plaws peb muaj cov ntab tsis tu ncua txhais rau saum, yog li yog tias koj xav kom koj tus dab txav nrawm dua lossis qeeb dua tsuas yog hloov tus nqi ntawd.

Tsab ntawv no yuav tau ntxiv rau peb tus dab ces peb tuaj yeem ua qee yam xws li "GetComponent ()" txhawm rau kom tau txais cov ntaub ntawv hais txog tus dab Animator (txoj kev ntawd peb tuaj yeem ua yeeb yaj kiab los ntawm tus lej).

Peb nrog tom qab ntawd tau txais x thiab y txav ntawm tus joystick los ntawm tus ntoo khaub lig platform tus tswv tswj tus tswv thiab txuag lawv txhua qhov sib txawv.

Tom qab ntawd peb siv ob qhov kev hloov pauv thiab txav tus dab raws li kev nkag siab joystick.

Yog tias tus dab tsiv peb yuav ua yeeb yaj kiab taug kev thiab yog tias nws tsis txav peb ua si cov suab tsis ua haujlwm.

Lub luag haujlwm kawg uas peb muaj yog kom peb teeb tsa cov dab phem hauv zos rov qab rau xoom txhua lub sijhawm lub dav hlau hauv av tau hloov chaw. Yog li nrog txoj hauv kev peb app tau teeb tsa tam sim no, Vuforia yuav rov ua haujlwm theem dav hlau hauv av txhua zaus peb nyem qhov screen. Peb tus dab tuaj yeem txav mus nyob ib ncig ntawm theem yog li peb yuav tsum teeb tsa nws txoj haujlwm rov qab rau xoom, txheeb ze rau theem txhua lub sijhawm nws tau hloov chaw.

Kauj Ruam 7: Tiav Touches

Tiav Touches!
Tiav Touches!

Thaum kawg peb tsuas yog xav ntxiv peb CharacterController.cs rau peb dab. Yog li mus rau lub hauv paus hloov pauv ntawm cov dab prefab nyob hauv lub hierarchy thiab nyem rau ntawm nws. Qhov no yuav rub nws ntawm tus kws tshuaj xyuas mus rau sab xis. Nyem ntxiv tivthaiv thiab tshawb rau tus cim tswj cov ntawv. Ntxiv ntawd.

Peb kuj yuav tsum ua kom ntseeg tau tias peb qhov PlaceCharacter muaj nuj nqi tiag tiag tau hu mus, yog li mus rau lub dav hlau nrhiav cov khoom ua si thiab nyem rau nws.

Hauv tus kws tshuaj xyuas yuav tsum muaj ntu ntu uas koj tuaj yeem nyem kom nthuav dav. Muaj ib qho kev tshwm sim Unity muaj hu ua "OnContentPlaced." Ntxiv ib txoj haujlwm rau qhov ntawd los ntawm txhaj khawm ntxiv. Luag tus dab mus rau qhov khoob qhov ntawd, xaiv tus cim tus tswj hwm tsab ntawv, thiab thaum kawg xaiv "PlaceCharacter" ua haujlwm.

Kauj Ruam 8: Cia Peb Tau Txais Nws Hauv Koj Lub Xov Tooj

Cia Peb Tau Txais Nws Ntawm Koj Lub Xov Tooj
Cia Peb Tau Txais Nws Ntawm Koj Lub Xov Tooj

Yog tias koj nyob ntawm Android lossis IOS nyem cov ntaub ntawv, tsim cov chaw, thiab mus rau cov chaw teeb tsa rau koj lub platform. Hauv ob qho tib si nco ntsoov muab qee yam rau tus lej cim (hauv daim ntawv "com. YourName. YourAppName"). Kuj xyuas kom tseeb tias koj muaj qee cov lus hauv lub koob yees duab siv cov lus piav qhia.

Yog tias koj ntawm Android tshem tawm Android TV sib xws thiab hloov koj lub hom phiaj tsim yam tsawg kawg rau Nougat.

Tog twg los ntaus tsim thiab khiav, lossis ntaus tsim thiab teeb tsa.apk nrog ADB lossis Android Studio.

Yog tias koj ntawm IOS ntaus tsim thiab tom qab ntawd qhib qhov tshwm sim hauv XCode. Sau npe rau Apple tus account tsim dawb (yog tias peb tseem tsis tau muaj) xaiv koj pab neeg thiab ntaus khawm ua si kom tau nws hauv koj lub xov tooj!

Qhia rau kuv paub hauv cov lus yog tias koj muaj lus nug!

Pom zoo: