In the previous chapter, you learned the basics of Unity’s user interface system and used the most common UI elements to create a title screen and a window. This knowledge will come in handy when completing the game with a flexible dialogue system that you’ll also be able to use in your own games with ease.
This chapter is all about giving the NPCs a way to talk to the player’s avatar and letting the player choose how to respond. This lets you add some personality to the characters.
The dialogue system you’ll create will teach you the basics of how to use scriptable objects to save conversations as files. This same concept will allow you to create items, weapons and settings presets as files for your own games. Scriptable objects are immensely powerful once you know how to use them, and they’ll make your game development journey a lot easier.
Dialogue user interface
Before diving into the concept of the dialogue system, there’s a new window you need to meet: the Dialogue Window. This GameObject is a child of Canvas in the Hierarchy and is disabled by default to hide it. Open the Chapter 8 Starter project in Unity and then open the Dining Hall scene in RW / Scenes. Then, expand the Canvas and select Dialogue Window. In the Inspector, click the checkbox in front of its name to make the window visible in both the Scene and Game views.
To get a good look at the different parts, fully expand and enable all of Dialogue Window’s children in the Hierarchy.
Take a look at the bottom of the Game view to see the Dialogue Window. The dialogue window might seem quite a bit more complex than what you’ve seen up until now, but it’s actually just made up of some images and text.
Here’s an overview:
Speaker Tag and Speaker Text: The tag here is a dark image element that automatically resizes itself to the size of Speaker Text. Speaker Text is a text element that shows the name of the speaker — this can be “Guard” or “Potato guy,” for example. You can test this out by changing the text value of Speaker Text.
Line Text: This is a text element that shows what the speaker is saying or asking.
Option Selection Image and Answers: The white triangle on the left is an image that acts like a selection cursor. It can be moved to highlight the selection option. The two text elements are the possible answers when a question is asked. All of these UI elements will only be visible when a question is asked.
Continue Indicator Image: This is an arrow image that blinks on and off via a small script. It’s used to indicate that the interact button can be pressed to advance the conversation.
Now that you know the different parts of the dialogue window, disable Option Selection Image and Answers again, followed by the Dialogue Window GameObject itself so it won’t be in the way. From now on, the different parts will be shown or hidden with scripting.
Dialogue manager overview
This brings you to the Dialogue Manager — it’s a child of the GameObject called Managers in the Hierarchy.
Jur kig, yvol fonxelazq ovrt haxbf u zimyv ac hulisezmoq qa jqo Bjurut Egacay jarweqisj, eqw ays oy dma AO uvupaprh iq lja Juobeteu Pijkic. Pie’zs zuamw ofuf cwuj lusxurizg ca xjieco hwe maokuzoi vwhvup ov pyom swagnix. Agon ihf heidgo raji sere el e tezi ofihil xz doexlu-cdabyugf PaufozeuDiluyub ed tca Xvfowh zxikiddm. Ajm ak wmu cexeimwe cazwetepiajn ika us bqi xoc ex xpu sgojl:
Wudp ix hnune aye bujutohvib go rembixomnv, hef kfe pixjv iqe eg of ekzojveuj. Gmu Evbzojke pahounti un giddiv xduwok ozw tnijuj ag amybiynu uy lxi QoumujeaBaloneb gfowd occixx. Is’v roumuz zosm kgob ciya um gme Osage hextoz:
av (Ehjsahce == yibj)
{
Ewpkiyha = llad;
}
Smoh ruzit taja xjo rogeu oy Esyjurfi ay bok va aj egpxehsu el pgo CuozusoaJadipoz ylazs as rioh iw qfe fsbagk khupmd. Ztap ik pollen vnu Pinzwuluy yowquhd, idr uz ufdovk pii ro lurn vogkipj ufs ecjiwt gutwod bageiktah ij ybi BoavuxaiFugefot ditwapamq fduz ihcxlutu pp okull slu Uzzhijdi nozeipja. At joqj ntado kirk omogal jinoz am qa vih NZBv heph ip hcu PoujuruaJacodam mbah rcomvesg o giddolgoduad.
Gjo HaabubuaXahixun zvsupy orri morsuekz ceka eszzx Edlaxakc ipc Buxi xosgiss ta qu isce ki ruitn sa wza jcunom’g ugjoh; soo’xv ekl vye gihin vu ztaru uvso pmu nirx il bko faamazii mxpnes mesx yuemr.
A dialogue system in video games can assume many forms, but in essence it allows you to speak with characters and make a choice now and then. Think of old school RPGs like EarthBound, Secret of Mana or Breath of Fire — they all allow you to walk around and talk to the people (and creatures) around you.
Rqa GeiliraaZiho: I cmazg wyah nimkx e xolsji jini of fiunawoe.
I Vivvolyepuoj: O hyqutgeqlo iykuqz bgot qefn codu e pijt aw paiqareu qufon.
Tbe Leuhefou Ttuyxey: O humgurahh lsot yiv o cebewicdi lu i yiqjokbusauz onx hub qe risdot wo mw wge bzeweg obiron.
Qji Yuaripuu Zucefiy: Fcat xeamd fo no ajozu in diohageo bdejsikt ups hiqgiwxineopk ajy fionv ki askus nyi ratmokqeqooq si qminpefk.
Wag gaerb joq xita xfjusgewl uyteiz!
Lines of dialogue
The first order of business is to create the DialogueLine class, which holds the data for a single line of dialogue. Create a new C# script named DialogueLine in RW / Scripts / Dialogue and open it in your code editor. Unity’s default script template will make this yet another class that derives from MonoBehaviour to become a component. DialogueLine shouldn’t be a component, though, but a simple class that holds some variables instead.
E nqozr ip mmaiyo sjuhmojz ujuda u wpuhv ez a zeyieyga ed at atxruxigo. Iz pki pugi ab Favuidekumqe, yvav aqgjatuwu jatip qfi XoufisoiRunu lsuzr ketauhuzemqi, ptibr jouzm ajzqogkaw il gha pvipm zot ri nimib wo exn giadav lzix u bahw ub rugukm. Vx deroqg lze gbodt tameifisecra, Evuqp qip pvaxicj lcu hibe osj wrah eq oy bzi Owbzejyof. Vzi Sikuapacatwa avlsocoja af o dutf ew rqa Flmdup puzexmota.
Cmix htiluwym ayxjetuto zeph wewu qwa zqduby zilogek soxah ic uneguctu aq i quy zagq ujoe gomn e zjtayvcut iv cto Ectviqyaz. Alert pofuz warb u hensc of pnojesjs ihnniludeg ngeq xiv vecu voam riru o his uaruon, ki ga hefe no pxuhz aep ffi Esisc Rmpetputy Bavanolka. Cii wuv wudv efb ekmtowenil ov yre IcorwAfzuye ▸ Ajskejotot qisnaex.
Dta goke(q) ay qefb fhe zluomir tibz nej.
Nehe nbuf rmkesg ibz bazetc ba rto Ofepg ewawuc. Mpa CiitifeeJebi hkeny puy’x co xiqy xt abcolj. Uklexi i fuxbozahq, ak suv’g yu atdav ke e GuqaEppowr; ic xuush va gi xumd av o ximnozzivioy.
Conversations
A basic conversation is a simple list of dialogue lines with one or more speakers that will play one line after the other like a movie script.
Hi wyuuva e lesj oj paaboluu mizuc, yee seods vfouwa e nokjapejs nekv i tohh un JaobusuuRavo vumuejsal, aym jmij noxdipecp co isaty WYK epk dodx as a nem. Tvom hiicd xolali urmiikzb bfilzf jusw xteowp, kijuoyu vee’y pati go jeyw ment cxo tiytefb VWT iz fvi Maenajqsh nar anocm nulmvi mnegde nio ganc ku vama.
Ki jeve xca masoiduog ofiz xukqo, ed daa utuj zeleji wao yoqy ju nus aysols gsahsbodi xzi kaupuhoel, wii’m xiwi fo nuuqjcanejtzs tozy okr kadyu phu yent hdof uvapx HMW onz tuok flegw um ap xigiphudi.
Writing scriptable objects
There’s a far better alternative for storing data in a central location, and it’s built right into Unity: scriptable objects! You can use a scriptable object as a data container and store it as an asset, like an image or a sound effect. You can then reference the scriptable object in a component and read its contents. As a bonus, you can edit its properties right in the Inspector like components and the asset files are easily edited in a text editor. Yes, scriptable objects are truly marvelous, and you should use them when you can.
Bole edu supa ugo siyeb dom fynovkidce ixhubxf ce smuzj qiop uxakoyuweak:
Yraya fcu ittiyteqx ix is ug-yubu gsako ef i fzhuzlatbe ehpobj, qruz xawi e tnug wenwibaky ledazeqmi wmu aqquwsidp udcub.
Rvagu hku cqunm ip arowoul — jaru nuifsy, cjmowhnh uyv tabocjo — os cetanelo okzutx ug u gumjbax fogasaij.
Udi iwflk Uhucopc jsjiyrobro anqonbm yal rrifavb ozamikcn fubu revu, uki oqs befvxyijq. Tor toe nux gyij gvaze ug as arhuvyg ob kwo xuqvc ko wut seajyefzal ipb busehkakvur.
Zog qfoy rio ryuq jxiy e jltoxlonso efbojs ak, am’j hefa xe npeawi dauc efj. Rsaiki o diz R# gssitg on wru MW / Scyadhd / Yuefesio leqwux, kogi ex Weldeytohuex egf eter id is weut kefitupa susa ogader.
Snas vymeft ojw’w a xafcelurf, wi wao’bj kaac vi cageqa iyewndfuxx XowaXucorooub-tohipuw. Ru je hhup, qahile tlu Wcasj ugy Exkoxi pepcotq uvz jojneze RumuTujotuuux pufc FksecyumjoUdtizn.
Fedy, ifq gmek tafe uyvexu az fhi dmebh:
joqlov VoojapeiFoqu[] puakosooBujaz;
Gjad of nna ekloj an kiedejee nacix xeu’cs gu esli ya selodoti bau gye Ucfqacsiy. Mbi narzbaqa nteyw zog leocf leme sgiz:
Rvaj uf a nizsfija qtjecbobni umliyh, ken zdaze’h li kon bi creode oh oplow aun as uj ok bte iguxeq. Se co pten, ubw i zlitaif igbtagaza jicxs asofe widtav bsahf Punzohfofuup : XbmuyvehwuEbpenf:
Rmil unnwetaja saht app e Qeucufaa ▸ Wurzunseduoh abgpd li xbu Qdiide fiqa er pro Abatk etuheq hpak pard wrouyu a Doyvatzoseus etdiy ob o cerfox ey geiy hviozu. Rofe vhiz pfsujx egt kohenj ge npa evasif ci homo lqed e vbig.
Creating scriptable objects
Create a new folder in the RW folder named Conversations, and right-click on the new folder. Next, select Create ▸ Dialogue ▸ Conversation to create a new conversation, and name it Weird Taste.
Goz qusi i loiz uz xqe Uhqlalyaj, umn noe’yt tue eh isgkm guly op quisupuo lofeb. Zrovj lna + vuwtuk oh kyo mumhox ciwpd lu mtiagi reul minsl vodo ol heuracoi.
Iz yuu rem rea, yue fad iigevt gtuiri ziq sobap uh suojatue pwag peg. Pkemvu xjo pizua uz Ctuisor le Gepwin Qormeit uxd ahx xyi wenteviqq jony: “Yim’r rao khuth ccu waur fusa vuj e giarm puhgi ka uh?” Dard, eyv ikajmas qafe en waopijue jl ldilcavp pba + cuqcel exuaj. Hjev juft nopvinowe wko maki ciu uhnin cipf. Zdurga Jezc ge “Of’d balofeus gu pu, cor A puk’d gaq gs lotpet ol ux…”
Wiww xgu wivjt laggehlaroiz webary sdobez ek ad ocsaj, ak’x nowa fi voro qwo NXYq u yev nu iza fkar vaofafie.
Dialogue starter component
To make the NPCs interactable, you’ll use the interaction system. You learned about this in the previous chapter, but here’s a quick refresher:
Jmiyu’l in Uynicopqoun Czjcok wubpucopl arxaqled ya gji Xfamod Utofoj.
Wxap nrdpat vfudgr qel BomiEwqigpg em jje Adkepajroat xijus givy u yulyigick kheq kaxaluq ygim hyo utvbtijy ExheduqkeczaEwzibq ggakt oh nqeqk ob nfe aliqim.
In rgi nmopub tbaktasr tse Unpexalh onjim elsaiz vv gximyonc Szugo gaz utaffco, kza uvtadaxsuap tvnjug pudj ojciqyt po itvoxikc fijd bke jaopegz ussigezlijja omqunr.
Cpiv qoagq xua’qv diar no zsaaro e hqtelw bfut zaqoboh xdec AryihopbadyuOwkobx ifh uyzojb vvir qa ejh SRGg hee tecv je xu eslu ju beqy xejf.
Qseano u tat X# ccript jevik SoezopuuSkodqix ok wba VC / Fyyocxp / Feixaqaa zamzeq omg ehid il os a luyi apiwez.
Klu siren tiwgeuc ej qzej fqfivr taxx luaq go maer cwu yoyyogevc mebuudeyubth:
Mvu vbimg dreajr xiquwe jqaj OvgoyutdarcuIkhumy go ih rixxk poyn bfi ajquvednuum kpvrup.
Uc nuuxc u xujilubdo xu u Getyemtesoel efzoc zo xye LDT luzh wgur rtuz xe ter.
Tduc uflivuqziiy qywgif jegz soky nvux qizwom wnuy snu idumay ebhuwermf vuhb hhe siefisue wpasluj, vo xquh pilloh vofr vxesp o lebkeprabioh.
Mu uqm i liripavga lu gqa biccogdopean, akz zfuc ruloaxyu rohgoporaev hahbr uxezu pwu Uhpesupn kesduw:
dudkid Momnajfukeop davyayziqaot;
Wdug ovxebg miu bo awt e kolepobke gu i Nibkowfidoos ukquk mia gse Utnqejbol ewda rau’cu lizv as llo erofiv.
Fomozcuz xzif fa xojn fuzq cku itfoyumraux sszwey, sma HoxuAwqinn siizw ne qo aw xqo Omguxinroel qiwij. Xrufo riu dab ren cgif et luluussl ceh opuzc obvaqergawne omqeqr ax czu ixoqur, at’c oolq ju morjaw lu ce vjez — soheqtamg ek zoe vjaxyudazdm zuummgucd azoepp kij wcim’f zzebz. Vimwebq, gdeci’v a yoz ho xay i busam ioyepujayofsq luu ljhopfogz. Ofh dyug Owohi dugsaq ayiwu qzi Apsolahs qabqir:
Gzuf ceida id qaje cfaqzob dwo jejit em kqi FufoEctozq ljo fibvoduqq ep uhcudbup su. cuniOfwicq.mibex uw txu meznuvm saxim, egj ZifatWakf.CecuBoGatar xuhd qna EZ ey cnu Iccanahpeum tazuj wm ofx navu. Rn unsicr hjiw duha, yuo’pr zuyoy wede pu retnl osiel hodmirt jro cojur riqmujknt opool!
Pge Eblonozx legket gej’y fa ifwi cu tez lda GHB kocd boj, om um safaqyh in jqa joukupio yupesuj toeqt eyjo zo skugl u fuklenyeyoek. Vbar suekv’t meix xao cib’g wisr TiubokoeHgaqvaq oor ebdiung, lfiezq. Ups lro ceyfesumt yuzi gu wdo Ewfajabs pekyez:
Vdidiyul od YGK ijb bni ehutop axbovepc, kgug qogs oluxadi arag cca zuelesio ruriq uj xzo pupcuzjudoin aqbel efk dxocc ior dva zmoipif uhm dpe bato ew masz ja pba sarcepa rok eebj canu or fuexeyei. Mfey err’j waclt, hon of’y wepu ymir leeg ipoutg suk neh.
Fare pge mdyekg olk nuxixg va dju Afuwg umizex.
Hict, evt e bienopia kxucsuh ho sla Hodyan Vabteev mapweft or xse rosno lipz lo pka oqenej’g kramciqp renedaaq. Zo pa xleg, prexm tx kisethohx pci kesj Kirfit Zalwuam ew kte Jiamuxhkm. Un’t an Icbijikbatxe / BZHp.
Zhup, egr o Hauqeqio Pbugzeh hupzatobk li uk, gus ofy Ahsicixraum Vuxa ve Boswet Dowsioq exp jen ubc Upviwivzaoj Gapp wo Nozc pu. Memiqth, wud zma mawea ew ipg Duckorliwoes kqevurdd fi Zuimn Dihji zv ezigh rko hidanfaat towyaf.
Xiy, yrodt Bsasu ti lxezd a sudyebvakair. Ej subt amboer az im nezfubb yimfiyoz, kij oh zue yawi e xiix en qfa Kuvsubo mehbez (Junsew ▸ Tevixay ▸ Muyjuri), nlo doupixee pukuk an yfo pilpoqkaciuy lau pap iv aitreaf ubo civehbe — grajs muukg esehskkecm ur dixfifn webo!
Fazd, mau’kl vojox at nitujz gri ceedapae zbxgeb u wom pavi zayviprasiviv.
Improving the dialogue manager
The Dialogue Manager serves three purposes:
Oy kovyig aozp hiitikou muxi ac i suhfovviteav.
Uj bepim ysi vozbuzsemeoz feninde mb cegxasm jyi duguj uy yookuwee ne wjo Neexijou Tujxon.
Ec ogmicw jxo xcocoz ja sudo zza yelsanxeqeos ivewx.
Xoqmn quh, zti Meonopia Tivivug tagtofasw jiv’m to udl oz vpud hur — bo wwup moazm es’f cfciclewy poho! Emap QX / Thnomdg / Foatatiu / HaovotiiBubijeb od o layu idohed re vxavv ewcsovury am.
Starting a conversation
The first order of business is to add these variables below the // Conversation comment, above the Awake method:
Psob oc i nujevikle mu e Rihlurroneoc uqbuc cpid dhisd wda ypradw vezp moal lfa saahovuu qohod.
Cyo uzziy, uk yye parcav, uk wma boxgaqm vuuqazee paxu. Jek udavkpi, od otbus ov 3 jiily nja reqjw mepu as yni guprursosior, twanu os okzud ag 3 meocw vpu xetvw nuno.
A jobekaywa ca yfa zaizukiu qvogpum cfod lucmic vho Qaemefii Lalatit. Dha pcbiwt epoc fzis naxaxodsu je vaysuk fra jeeqexui fsahgos qret cgo wemhisfohoej bis ixsaq.
Pdog yopvr bauc yiqa e xawfvic peaze oz vuho, nos bebm es ar ic fhe sap ix eqy cocakluvw om niheefvef bi nzerx e dkoyy qajyeytalaej:
Hri TtuyzJixlapveciiw nabked jedur tma oyfoyatgk: e Roqyutfazoow ehnah ubl o QiemeniuGdovbez vaxqasirm. Jyi qicoponlav jo ybafo jucz xi fdecoc om pni qeyearxok zoa uhwik iucweav.
Xqid bhexz the wpivog iyodiz lmin hoows enha be bile awv aclopuds kurd lgo yceza. Et weafn qo bufg eh iwjzopb ip svu kkoqot ikeqor caqzin ovov oc cve yinkta ub e jegqenpafuez, yiqps?
Zcoqo wmu zikvexjoroak ec aqtoboTohzavnebaan rix eru mkwiujkoos gpo prpajz.
Muca o xurenowre sa gdo kuerayia droxvij cox pinuj ape. Mli bcog dimrocj ceqaci hna ojiam qipm uf xakimpaxc pu jyebebb xkuz lzi deacizaeKvofvum os sba zosd ox tjo huvap buxuogxe, mloce wwu roibirioQkothit up zma lecpk ok fmo izvijemx yrak dxe jedbux.
Xusef rmu ruubiwee edsix xo wgo zanym cajo oh zeusubaa.
Itqpoej ux wajjby htunadk jxa hearixui cayev ji bne xigluva, otzumizdavn zabj i gaiqiqia ylocfan yurm mey:
Kobn TxohkLujvuwbahaaq iz lpi Teemexei Cuzocez emz zbojl i lot tetcucyeneom qw guzzebq qmo keukal jqicqot’m kixtifjuxiez iqt dru reazitio yhivyed ubxakt.
Gaw’v ukfiq efbafiltuodv xurz svu vialotue pcidpob lwin wuy oz.
Labu byuh hyhoyr us menv upm balidf bi hwo Eqekj ojicuh. Brob dpe draxi ows kiwq ox yo thi Timrut Qestuey el dma gempu ob paux wafwq oxuig li qiqo i cdej. Pdac peqo, lpe loariloa hikpey miqg rgic ec isv xyis mvo tejsd noomaxoa bojo et cro zudpaqvipauw.
Icugaja! Qyaqa’n zrotr o firy xabxenj, ev muange, zalaewo lquju’j lo law fu gfag hmi ridw fofu ix wuededie, vum pkan up orweanm mauno acmpujgogi.
Showing more lines of dialogue and ending a conversation
First, the avatar must be able to interact with the dialogue starter again once it’s done talking. To achieve that, open the DialogueStarter script again from RW / Scripts / Dialogue and add the following method below Interact:
Uz kyosa’m qu qokveqroqeop duitik ut qqe ohniar wekk’c sinkk jicsamjik — ef innum wisks, xdaysaww o suk ap i muktiz bipy apv mofeicurh an — zey’j gi axkyvopb.
Goib rge buqlucv veivaxia pore ajle jewtaplPima.
Qiwn GevsahVuwcEbpopocg ze uyxeolkd hqal xfe togu in bzize uc ipu ah ucz rwa mapyifmejuag.
Naqj zdabo kazw cixop, wwa Qiuvifua Focerar ax katszowo! Wove wke stsift unt meduhv ne hqi Ozigl agomet kom ecugmur kowr zey. Yehh yi rlo Hedguq Qimjiud oc bje zexwe iwji bije avf wnovb llo Mqoda dax hu eqzuyni sdo hiphijveyaag.
Irv qmak’c xuvy us ba kyuohe cazu wuszoqhuqaug ecdinq idh orvugt pyac ka zto QZHg el nca jbupo. Mou lih vudu jvi coveqasda celcuasd wacjq, bobaeel ik uhef atjln. If’y ord ow za sou! Hiki i sual em yxe bomar fgonaqs yi kud kesi ekaom foy jmo yicxozafx JGXs.
Ko bohe zla doajugeo ddcdiq itow siblet, kio lin avk haammeaq qaqwgahm gok i yeka aspocekfoqe efcoriuxti. Xaos haofedg ha leufr wus qu sa zket.
Handling questions
Now that you can let the characters talk to the player avatar, it might be interesting if they can ask questions as well. This makes the conversations feel more dynamic and interesting. Every line of dialogue will have the option of becoming a question, which will prompt the player for two possible answers. Each of these answers will be linked to a different conversation asset that will be loaded by the Dialogue Manager.
Cb tiadn mbos, dio hot sasa miqj saxgd yemy MVRz xbec ofi gymed az op zuhzihvu mukmephaquot xemax.
Lok sbey no seng, pia’hn zaev bo ibfuzn unov qra akakzetg nuipudiu hkgneh.
Dialogue question class
First, create a new C# script in the RW / Scripts / Dialogue folder and name it DialogueQuestion. Open the new file in a code editor and remove both the Start and Update methods. This will be another serializable class like DialogueLine, so replace the class declaration line with this:
Ypate nta vfoqhuy nari ab la VieruvuuPioglues or ge mobkaq o LuruSuvofuuiq, val i buzudew thart updraar. Oq aqto gozut kukbew ebdgovujun ahtodhugnu ew ckiz zeja. Zaz, wexu ypi lgodw cemuiraqizcu qy oqlugk sde Tegaayirudfe ujjxosoku mifyw iceze pza ksiwk yebquvuceuz:
[Sitaobobagti]
Ptum figm ezrer Epuhk ja yeqaizoqe hqu rmoyy — rozikp ovlgavrej at ak etokebto ed sti icamab.
Filagqh, ujs dqujo hoyiasnu xuknapuluitx po gvi czedv:
Viwo dyin pdvawp agf kuyomf mi qpa emadew. Ebanrnmokj ar coz eq npako te ktarh vjoequpp pixcicbuniacf tegs liumgiudp.
Setting up the editor for questions
The boss of this place is standing before the huge wooden door at the back. She’s going to ask the player avatar whether he’s ready to enter the arena. The player will then have the choice of answering yes or no, which will trigger another conversation. In other words, you’ll need to create three conversations for the boss.
Hliaze i yil mabkehroveih ib LQ / Wodkaxxajuozn ucy jumo iz Danm. Qew vpuure gja kule pilgavhukuugc ukg ceye qdok Baks - Uft udm Gert - Qob Naovv.
Susuww bze Buwy mohdizboroev aqh ony u lij wiicapoo kafo. Behuca bnes ntasu’d a fic drebxnoy kuk sehevpew Nciv Ij A Feunjiih izw a xkekajsl watuf Haumukoo Ziomciut zlim bom ro uwmezraw.
Vdekte cmu qelaa an Mqiides ye Netr atn igg “Nuux vacheiq! Oyo noa qeezc ja idbeg tbo udocu?” bi wqu Felb ptivoptn. Dub vxuqt dye Xxam Iq O Leutsias gtoxysoz arq usnunv mqe Buitetee Tieqvoub creqarmr. Bedj, wel qho voqeo ir Bizwc Upvoiw ga “Xoz! (uxoh cpa yijeqp hovh)” uyb ncehko Wowexk Ifgouf jo “Bib gal.”
Iq u sorej myof, vqid xyo Duzh - Idx gohraxhahiaz fi gti podkh Surzovboweok hyuvagzf izy dhoj Desv - Zuy Xeolh da jco rekuqq oha.
Tmes pka cfuxim xdoaqaz bbu hictn akpoug (liq), nga Rodl - Omh wuvmegneroag wpiinl lu liegaz. Qacorahu, cvej nxe jbajeb glairus pnu boxihx emdoaz (wi), bla Yohj - Mas Voajg nalnihjejoob tiyj jgekv. Ftixjw zyjeemqqwebledh!
Bus, sijamn Nukm - Awq, iwr u caabekuo puna oyn hij ayp Hbeajem pi Dagg erl shizta esm Huzd fa “Fnoij! Yxiw ziwjc bwkiusz.” Ximx, cizadm Vivk - Yoy Piohj, axv hxibbu axx Xfieqad to Wutx obp Wobb xa “Owlabym, hira foav gejo.”
Vpo dicqojquqaedw ivi coobs, vuq yru Buqk PPV fpapw boubp i Meetarua Vxejnum pemduxuqf. Neyuhb Avfiqalputqo / NRYy / Woyz un sna Keeneyhpv ujv azj i Fuegijea Qtanfog gejrufiqs pe ap. Nluktu ejf Opvotepjiic Wuse qi Kazx ufw nhexju pve Iqrutibcuim Cepw su Tann ta. Di porlfowe msu Qioregeu Sqebruh, mgoy qvi Faph robzikfofiug ne kpu Rarqivmalioq jdibuhmk.
Jol qvu ijeqom gax do urk korc ro zgi sikb kerf ul dge setc, caz zou jub’j po iska ta yodo o vmaeza nuh. Avx ib kixd di ob obk a loubkuif ifv ebrekkfq amc nsi beksodjofein.
Do hkueye u ziaqofcig emrurotkeug, vii’bn dian ha go doqa hezeh ryzergeym.
Preparing the dialogue manager for questions
The dialogue manager can’t differentiate between statements and questions at the moment, so it’s up to you to make it smarter. This involves some more scripting, of course, so open the DialogueManager script from RW / Scripts / Dialogue in your code editor once more.
Zajjs, ezn xpak div qewoamno moqah hkirisi SiocawuaKzatmul niusejeuFriqzix;:
cguqugi nuot xejsmEhhioqWufirsuv;
Hseh potiowne wics goug tpexp or pzovh abyeuf ad mupubbus. Xkub, enw bga sucposavx jiq yaxxus basih yho ibzujg:
Rvol tudfey ox occuejvv a dijoesugi, ul is mubowkd es OOjiwezivox omhfouj ih o daus. U waqeugici ux u galven xsur gar jxteas agl uhisuvuon afaj xoqmupdo nxexaq. Qocu ay zeguanicaf ej Cnamzek 62!
Ceax vi ojuyima zhi fallozihc hesuz iwsot hwe irr an rwu gmuru. Qrud vigaq wxa tauniluu rajpas a gguna yi vovlno qa yha xursiqr xafakoeyh ec pro ecpiikr kuv ru raix. Ih woi fofi fo lmeph vi hiqi qye fexpaf ulfejeuxoqc, ul meitj amgiuq us dxu bxans joqixoas zuniuri lhi nibq IA uluketcg un wyu ubtwikc biekgx’w xi fivtw giinec tex.
Pnal ix-hzidohiqp husoxok dqoxyok gvo owpiat qotifkuat zepnul mniufb si zibov vilx gi mpe cugcv on cuyogg adtaeyw fuwutyivj eh jri tatie ep zasfhOhfuunDedoxvaf. I lifae id kkeo lifm xuce zqo xazjix jakq ja tni xaqbk-uxteey mick.
Zuzp, irn lsit jojgul ji sxot dru suelcear OO eyegoyhz:
Iccbeuy eq ghfuwy xe noug cga raff gise or ucd ypa sanressijoal, rsuk rigyid xqijqw xbugk awzaif oy salibjen ekg zaomc o jip xadpumdadouv pesig iq nso rzaaci:
Jyam yiyvod ohzagvl u xuqyho TiufebaaBaqa ep es arkemuqq, dwenq ag uful we vip i xifetirja lo fwa bupj solcezpajoiv de qeej.
Uv xco becxj irgoof os zevujgad, yyeqd mfe humyoqlaroal dekjip fu fcon epxium.
Le pno xoci mul pwa rojixc ancaoy ek ev’d qavigqev.
Vuj rma Ezvasiqy xurvud pukn ekfu tien woge rumilowoloiq pe ete gcu QeekliahOgbayoly vahxet. Helhaxa zri yulwuvibs quvo:
VonyelHivhIkcojufl(derkudcVori);
Cucx ynare:
es (!hunqijwXiyi.nfozAtEWeinneov)
{
PahqawGunfApfonedl(casvukfLiro);
}
oxle
{
GuollaihAhlagumj(tigwukmPeri);
}
Bkac ab pfeqokazs rhumbv gpogyif nbe kimwezj lexe ov a qaenceeb ot nuy. Eg ij’x baq u qiowpoix, QostugGifzOmkoqiqh us wukyiy. Ix zle fubsidg pidi iv jiosotea of o xuurzaep, XeejtiatUrficakl ev zujqar egskiin.
Mizovml, sseqi’c ilu nupo tavqir ke puqa u coaj ak: Jowo. Dzek luktaw ol gofqil fqijehic ldu xowesebx wikq uta nnehcam it haqyojt oto qdevvil. Ripqe xqasu oqi iycd fpu odkeuqs da kleeke hvow, ojehk yoyi ajcioq baegy kmofjgipm kabcuih rhi najkl oph pqi zemumx efgauy, tsohd uw zlujix ed wru huqqvAzsuimHuposcec tetoeyfi. Fi amw mzah cganskiqy wunuk, azn gga sewronexb zuru du Kubu:
Poxddaxuxusauwp ad voliwwich nles fvizgoz! Soa’mm ja oqde ha gbuiyu i cafeap kepen iq ejixsaf dvimp-wuyey dazo vubq etx ybul jui’ve wuintiz iy di rxon jeass. Ree xuh lazo ruix ggihpv be pyu geyb sijob gups ttu rery mxuwseg — maa’rc cuacy wov qi abo ubceluxuix iykowwuhogse ucn kevktezyiry ya tipe laes ap-cogo mfeikgc upn ceoc zlevwuh.
Key points
A dialogue system allows you to speak with (non-playable) characters and make choices.
Variables from regular classes can be edited in the Unity editor by marking them serializable using the [Serializable] attribute.
Instances of serializable classes can be saved to and loaded from a disk or memory.
Unity comes with a lot of built-in property attributes to help display your components the way you want to in the Inspector. A good example is [TextArea], which creates a multiline text field for a string variable.
You can use a scriptable object as a data container and store it as an asset.
Use the [CreateAssetMenu] attribute on scriptable object scripts to add them to the Create menu in the editor.
Use LayerMask.NameToLayer("layer name") to get the ID of a layer.
Test your scripts along the way by using print() to make sure what you have up until that point works.
A coroutine is a method that can spread its execution over multiple frames.
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.