Now, thisaltargeneratenoticeherewhen I hoveroveritsaysautomaticallygenerateslightningdatainthescenewhenanychangesaremadetotheliningsystem.
Thismeansifwetakethisdirectionallightandif I evenchangeuntil a bitSoif I changetherotationfrom 50 to 71 itwillrebakelighteningitwilltrytosimulatelightning.
Andthattakestime.
That's thereasonwhy I haveturnedthisoff.
Peopletrytorebuildthelightningsettings, whichwilltake a lot, a lotoftimeforus.
Andnow I amassumingthatyouhavecopiedallofthoseand I'm goingtomoveforwardandgoimmunityandinscript, I'm goingtorightclickinCrete a new C sharporactualnewfolder.
Andthisonehasbeentobeourplayerscripts.
Andinsideofthisfolder, I'm goingtorightclickinCrete a C sharpsquid.
Sohereinourunitsneakknowswe'regoingtoseenodes, whichisourarrayofrigidbodiesor a listyouseehereofOrigenbodiesandwearegoingtomakeit a newlistoffrigidbodiesandbelowhereweregoingtosaynodesthataddtoaddtothatlist.
Andwe'regoingtosay T r, whichisourtransformGetchild, andwe'regoingtogetthechildThat's atzeroindexthatgetcomponent.
Sotherigidbodyoftheheadsnakeandweknowtheheadissetatindexnumberzero, which I explain a momentagoNow, inordertoinitializeourplayersorightherebelow, we'regoingtocreate, innitplayersimplyherewearegoingtomakesurewhereourplayerismovingleft, rightorupordown, Soswitch.
Sowe'regoingtouseswitchon, we'regoingtousedirectionandwearegoingtousecasesinoursearchincasesowe'regoingtohavecaseplayerdirection A rightandherewe'regoingtousebreak.
Sorighthereaboveourinnitplayer, we'regoingtocreate a voidsetdirection a randomandherewe'regoingtosayindirectionrandomordi d I arerandomisgoingtobeequalto a randomthatrangefromzerouptoandweneedtosayherein't andwe'regoingtosayplayerdirectionthatcounttoconvertthecounttoanintegerbecauseifweuseitlikethiswithoutcastingittoanintegerandwegobackinunity, wewillseeherebestofoverloadedmethodmatchforrandomragefloatfloat.
Weneedtoputthisinto a floatoraninteger, so I'm goingtouseitlikethisbecauseourcount, ifyouremember, has a valueoffour.
Onceinoneofmystrugglescanrememberwhichone, butanyways, wecancastitintoanintegerbecause, as I said, thevaluesforsothedirectionrandomwillbebasedonrandomrangeandnotice.
Herewearecastingthisvaluetoanintegerandsimplyherewe'regoingtosaydirectionisgoingtobeequaltothe I R aroundthemnow.
SamewayaswecancasttheseDenham's toaninteger.
Wecanuse a newMaraisshinstocastintegerstoeathimsowecanseehereplayerdirectionnowbasedhereontherandomvalue, let's sayIran, thevalley's equaltooneSothis d I r intorthe I R ranthevaluewillhave a valueofonewhenweconvertthatintoourintoourenumerationplayerdirectionandwegobackhere.
NowwearealsogoingtomoveallthesnakenoteSowe'regoingtostayforint I, whichisequaltooneaslongasoneor I islessthannotesThatcountare I isgoingtobeplusplusandwearesimplygoingtoseehere.
Previouspositionisequaltonoteselement.
That's anindex I thatpositionstoringthepreviouspositionnotesanelement.
That's anindex I Thatpositionisequaltoparentspositionandparentspositionisnowequaltopreviousposition.