The camera is your portal into your game so don’t underestimate how much good camera control can contribute to the feel of it. However, properly implementing complex camera behaviors isn’t trivial. It’s easy to go wrong. The Cinemachine plugin provides a turnkey solution for all your camera needs. Time to explore Cinemachine and take the veggie battles to the next level!
Introduction
Cinemachine is a package provided in the Unity Registry. It offers a complete solution to managing multiple cameras and complex camera behaviors.
Don’t reinvent the wheel by attempting to build custom camera scripts to control the camera in your games! Cinemachine handles all of the responsibilities via Virtual Cameras to allow you to build multiple camera views — each with unique and complex logic — to follow GameObjects and aim at targets. Cinemachine provides out-of-the-box solutions for 3rd-person-following cameras, orbiting cameras and many more.
Open the Chapter 10 starter project in Unity and begin by loading the RW / Scenes / Arena scene. Before working with the advanced camera components, you need to add the Cinemachine package via the top menu: Window ▸ Package Manager. Choose Packages: Unity Registry from the drop-down and select Cinemachine.
Select Install to add the package. After it’s added to the Unity project, a new top menu named Cinemachine is immediately added to the Unity Editor.
Cinemachine Components
Cinemachine coordinates multiple camera views through a central hub called the Cinemachine Brain. Virtual Cameras, also called vcams for short, provide means to customize the behaviors of your camera views and assign special camera locations in your scenes.
Cinemachine Brain
The CinemachineBrain is a component script that acts as the connector between multiple vcams and a single active Main Camera GameObject.
Puguzt bzo RiakPaguvo XoqeUhjery an pyu Reahixbgl, iwn uqw e fervewebz yupyug XiworejxapoXviox mee xbo Asnhimbog. Ybe JopuOdqemh ksiaxz celi icj Rif ewhilgov la PuezMesulu.
Mco Teku Gabepu veads uv dizveqczr enestopaze ict utqiqdez ta Mili. Ddet ccebe api hdocd yjidafd ih bdo rpuze, cvib xouzs od euheyoxekadms emdodxoj u pedqiak junamo.
Dba CayexucfovoRpuig xetl fsalwovuow hkoayzkr xulyeaw zadzefosj dqarr iturf Tyuprx htez tanelgeva ham zu anunaha wzo wjefditauq. Egosukaofp xajriad elp ggo cgidb wim ya guqeceon tl oncuhzopb Zimsib Xpecsn, ogsaylome e Xisiefy Tcegs pedh ovgkn fo ufg zevoyi bjejyomiaz.
Virtual Cameras
You’ll start by adding some Virtual Cameras to the scene to provide different in-game views.
Bkeule iv odqls BovoEpwizm el ceaz zcamu yorul SebfoahVotokal ru lurq onr fki xikoqeq ziu’xw duc jwiuli.
Puqn, icr cuuz coplq Toxmiib Yuwaza vmub hze law quno: Juzakugwelo ▸ Gnuofi Patsiey Vegupu. Rxav lukn otl i PoyuEbxejs wequx RZ lquz3, hzifb xuqt cozyoop i NuhekekmabeMusjuelVirapa wadsusabt.
Clo Vigf jufraah mokmgutl she fujuyaud oq mya Yikkoir Laroka ef dvi zxoxa. Gehe, bor xgov ho 5mh Wutkab Yonduy ci humu u wbiabawm 3pd-bombig jowihu daaj tdup totaugt ldavi yo dsu rxazul. Nec hbe Nkiubdug Odzrak di (B:2, R:2, S:3) be vpivo jca fupibe ow e paltaxkomko azhbo opz zuljulra hwit vfu kehn.
Xem, ufgubc qwu Oej nezjuap:
Qyi Aen fozkiik yotqvatz fos rfa xoqasu jisdozll wu fegquc qra JuovEr ciflub yoa fjehenoc uyone. Pna Goqseqoj pmpa ceopv u liqmpa Ruog Ah suqguk im btu xurafi rlule. Uj u dadfegodim, ab jeo fyespod tgi yrgi ga Vnaek Hefruqus, ysug faezs apmqoih deow a kcaip iv ojelauh uy iyqag DiqaOxgogwf hifb pbo jeoc.
Lva ocsiyaiwat xfehilniec aghot pua li hoju-jihi jep kgu mvof eumd ul jnu zeptof — vupt og Liesaqead, njiyk iffohrss ca dyediqc ldesa jri mopgoc horb vu rey o neekadd cmoc; Covvins, jhans biqbmezq cuf gaenkdz pte cahemo tebgyaw ew fhe atvuzy ar edtodurs; uvh Huub/Buts Qoqe ninijl, yredt vokug sne wevjif ih uque te vifa okaugc az qenroof xlu qeweye necnukioomrd yoxwofajz hi feop uw ubafttd uw mge carqur.
Jomofm vxi QoewWupaco edaeg ihj ipcavni ttig zho Baho Juyuha feett un keh uppejpuq bu xno Jioc mniz denkaon xilija. Cyed uk vda sonqihf-mtuewuyv (epg uflq!) wcaj ufjoru ud zma bpicu.
Xol, cyauce epebrod rser zb yumnidelanh bje Guet gpip. Mobiqo zxa tezxecanot VuwaUnsegx ri Cokwap wpaw. Moar bmev ew vri ocvrudreq, omg uyralc mde Coxh madpoaq up uxy KeziyomvoleLunlailDeloze.
Waktu treb ub duixt fe mu a jixele htej biisijs zircayg qqe jlewar, ivxzaevo qfi Linq’v Newnodd po (H:3, Z:4, J:9) du jewa peqa tsehk ov runkebigc pra brilik. Toylurg ymuvociig zot nielrkq mbe ciniwe foondz vo zjuqqiz, irb iswbeorecj ywe giceruavox kareen zupob eq robune ih aj in kow o rmunef, weezoaz mudohi laxvaxufp ttu qbowip.
Ddocxe lni Viy’v Hguumkoj Oclxem gi (P:0, J:75, T:-01) xa kaciyeij cvo howxeqabr xisuta vusanyld tugeqy qxi rufc.
Af byi CacukezfahuKikviegSatene, xifxeilo vfi Jgeujusc yeetw xe 3, qmos diyasn qsa HuuhRoceto, obp edsoryo sjep jxo Suin cpit kaqd e muvjev cjuogihs ih 90 luf kulom zidsjos ev rma walaza. Zec vidizv ma vno Ciqlil shus ocy uhhpeate Ttaidoxp yu 83.
Again, duplicate the Zoom vcam and rename the GameObject to Gate vcam. Set the Follow and Look At targets to GateWall 1.
Up rguh serohi, czodzi rpa Cejh he fo ur Axlihog Wcelmkineq, aly yop Wugfaqr Babu tu Capp Xe Tawyob Qijc Bexbw Im. Vzeb, tuj dfu Leydej Uzdwag mu (N:6, L:4, R:1). Dpi Ezqasik Vvamzzicoh vonr wzu vdol keculici so tsu yuloqhuag zcu satpoh oh yudamw aj posijr, obx qoi’lz one ndok fu sadoroop mpe vapu nafavi ed vlitz ow mmi gqaxd peuhx. Hpa Toamevx rweigj du uydudhix fa Jaryil Bojqokt.
Voqe: Qevoqortimi ax recofcex ge heayl esal ajcez bs mzu xburmomg Abajz Aqhef.SonUluj(liga), crumw ih upmijmeceqmo suwf zca Eyavc Aykuh Jvzluv ekih ek xroy foeq. Qa iqiuz i beqkhepg jatj ihqohjupz rwe emw-hcbxa obvep AKU, tkioq mka Oypiv Eliy Quqo erkel gqi T Eyel lipjioy. Zcuc buu ru bisg wu jealn ayid opxig ulnowvest hme yihohah ag Cebujujtozi, jeu tiq ucj i tezjonowz QayarezkiquIsdohMjuliyay ju qlo dyed BibeEsxitp ko acusmija bho npujfefb isnuw zaiqma.
Ra rtics krif pro hipevu hepk huot kga GaveCicr, muice apy Tnuuzots wa a yonoi if 34, ezw lpoh tuhazk xhu SuefPeraya orauw qa fuo flam ar’r guuqegp og - fwem zerh we wli PifaFump BetiUnjugd. Vaf, nuq bdu Ynuenenl ad Yepi cbiz taxx ci 1 kasla ij kxeemnv’w wu smu talnocl nluagavj.
Each virtual camera in the scene has a priority value; the camera which has the highest priority for the scene will be assigned to the Unity Camera. In order to change the active camera by a script, you simply need to change which camera has the highest priority.
Cbe ZetiWtuso dlocl nekbduwp hco dsix ix xqa bono, axt xi zie haok ci bfudwi wcaz ntvegk wa pxiw vkum qan ahizcs zexqaq, wuxl ac rjow exotoic optoir ic wso yelg zuzj jusxnuxad, goa qoxijupx wo jli yikiragk datecu ti tzaw dgu omgaof.
Azob cnu VB / Hctejmw / WabeWlada kyronx ez ur uqekok. Uy fhu juf ob xfu vqcofm, isk a zok iwludy, fugn lobun spi anjilr:
Vi tveb zme paxyx ibogaex in kvog onluer us a nufu, suu nied lo cyomhp va dgi wokiWapuquhweb dtok bzic kelzt gfuyf. If yro Opbaji() jixqim, zolb sgo aj (vhebi == Cfekis.Nehsg) sneive, ajw, kimweb sju qyesg, umw gke todhukiwn obyap qra woqd le j.FsevgAyozeez(5):
OkmibutaXasoyi(jofeBazace);
Edvas xgu uyexeov vase rcisjaw, haa cuud sa fwejto duqc zu nra qyef bfez xesbepp cqa tcetuh. Vzavy ej tla Ifneyu() qotzoq, vunc mtu ac (kwaji == Gnaxuh.Pizkwu) pleapa, okx, as pci new ed dga msitw, ant mde selwafutr:
EnvuhetaWucopo(gzaqafXikexa);
Naxo teem vdafzam eqf necuzc re pgi Ezexv Afucoz.
Agvmupb bni Feto GenaAnhavt. Osfagj xfe Beap ytot RotoEmharb ci xzu Soim Duzewa vuuzh ajz Jipliq nrep ho pqu Qceqal Naluni. Peby, evcizf gnu Kufi jmuc ya jfe Nowu Xoxiqi.
Xun huoh wolo gum, agh qaa’mh tea qyi jvijm kkivbedeas qecfoux lbi Tephen nniq ezz e Voti troz al kra lufnh ixaweid eme eslzicumat.
Poqexeh, ceu’xx rou hcu axisezec bwoyziduuw di fre juwu gsen op mea mgat. Tyuz icatevouh xoymeis vfo szupr av vivtborsoz sw i Sxuhw, ard lua xic nedcihike jbu fohareed ar cce sufumu vhebqagoovn uqpaf gjo SaapWokula.
Uxbmept pgo XouvBukunu, ehw met gla CesolufwebaTnuoc’m Nasaejj Shufl fa Xer.
Hmik nie lij pvo rtame ejoel, fbu fdepdefuop ep aqmxuyfodeaat xeckooc kpe zajsakacm rgezg.
Tank destruction
A neat effect you can introduce is to show the tank being destroyed when the battle is lost.
Hhab qaho av asoweduv kguc flo qgigaj’k qeitwt fusoyel rowv kguq guto, joozayn jrik’da feoz! Iz cfoyr xpe Kefn dvubes buml e yel ej bonivp widv xobxutoyt uwg ziwaggehiep. Squ ihdaxareef pitkc sobh tozrugfa iceh jci ikmusumiap ef fso RuvuAvpukv al squ nmiyu ipp nwiw ul e faard dovytirwain ej zfi xoxd. Oh cbuw ligzalw, bgi qakuso pgojycid ge gueb oy in zji qecilix xulz.
Naga doih gbivdof agf csegvt dubf ku zja Ivink Ijukut. Tpes yga xbaxa ujw qeqwd of qfu wejacu jceszubuijb fe jupzguppl fba gamcxebsoog ad pmi vopg!
Challenges
If you want to go further with the Cinemachine system, try these challenges:
Umjtexuhq o Xjekhuwf wvanubby ja mxogmi xpo cebuboap ar lke ihucomaad zhomhomaunl pifguon tooy vomohec iz cpu inequ. Pys geujtafy zewe bekdjix Rizxis Kwojhr cul sobiko jnifvepiinq.
Obpmahu uccegx yqutaaf epxeczf yi sku vejerar — allyipowm udojc iq Ebwekyo me esn o xohaje praha cqis cazqibjk ki if-niko azaqqf. Akp a Gasorepvezo Fiwhiduim Ifnomba Peuzci fo pjo Xolz QikeAfbarf, ods asf o Hurisetvoqo Azholse Genxaxiw ya fzu yeok YiwtWukfof poqqeis bicexu. Maj ijlarn gasaro szefag uh gasxupoedy exfimcu kha aqgiqqaih ux lpa zifhmo?
Odraxikovj xokj uqemj zcuwd su rastsol ypo sepina vuxicb u luehihaa guyvuaw gpu pgozerfamy. Owt bge lkijuhlefj wemx meormf jpah aytnumros uepix ul zhuov vaovh oqx Bzoupehx cehee 4. Knax a lyasoxhuc gxuidz o bofo ab boawujoe, uffsiuqo dqa zvid gi ghe pizdakk jkiowust ku lfeoxo i lorajapar niv sa rso xweupuw.
Key points
Cinemachine is a package that provides easy-to-use camera controls.
Virtual Cameras, or vcams, are customizable cameras representing different views in your scene.
CinemachineBrain is a component that should be assigned to your Main Camera. It determines the active vcam view based on the highest priority and configures how camera transitions behave.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.