Cov txheej txheem:

Yuav Tsim Li Cas 2d Tus Cwj Pwm Nrog Tus Cwj Pwm Tus Cwj Pwm hauv Unreal Engine 4 Siv Cov Ntawv Pom Zoo rau PC: 11 Kauj Ruam
Yuav Tsim Li Cas 2d Tus Cwj Pwm Nrog Tus Cwj Pwm Tus Cwj Pwm hauv Unreal Engine 4 Siv Cov Ntawv Pom Zoo rau PC: 11 Kauj Ruam

Video: Yuav Tsim Li Cas 2d Tus Cwj Pwm Nrog Tus Cwj Pwm Tus Cwj Pwm hauv Unreal Engine 4 Siv Cov Ntawv Pom Zoo rau PC: 11 Kauj Ruam

Video: Yuav Tsim Li Cas 2d Tus Cwj Pwm Nrog Tus Cwj Pwm Tus Cwj Pwm hauv Unreal Engine 4 Siv Cov Ntawv Pom Zoo rau PC: 11 Kauj Ruam
Video: yuav saib li cas thiaj paub tias lub paum no tsi tau mag aim li 2024, Hlis ntuj nqeg
Anonim
Image
Image

Yuav ua li cas tsim 2d Tus Cwj Pwm nrog tus tswj lub cim hauv Unreal cav 4 siv cov ntawv pom rau PC Nyob zoo, Kuv yog Jordan Steltz. Kuv tau tsim kho cov vis dis aus ua si txij li thaum kuv muaj 15. Phau ntawv qhia no yuav qhia koj li cas los tsim tus yam ntxwv yooj yim nrog rau kev nkag mus rau kev txav mus los ntawm 2d dav hlau.

Kauj Ruam 1: Teeb tsa Epic Games thiab Unreal Engine

Ua ntej peb pib, peb yuav tsum paub tseeb tias koj muaj txhua yam koj xav tau ua raws nrog cov lus qhia no. Koj yuav xav tau, Lub cav tsis muaj tseeb (nyiam dua version tom qab 4.16) 2D cov cuab yeej rau tus xeeb ceem thiab chav xeem. Cov lus ceeb toom, tus lej Epic games YOG xav tau los siv lub cav thiab lub epic games launcher yuav raug siv los nruab lub cav. Thawj qhov yog thawj zaug, tsim tus lej Epic games. Txhawm rau ua qhov no koj tuaj yeem mus rau https://www.epicgames.com/site/en-US/home thiab nyem lub npe nkag hauv lub pob ces nyem rau npe thiab sau cov ntaub ntawv xav tau. Tom qab ntawd, tom qab ntawd peb yuav tsum teeb tsa Epic games launcher thiab tom qab ntawd teeb tsa ib qho ntawm Unreal Engine. Tom qab koj teeb tsa Epic Games Launcher kos npe rau hauv lub launcher siv tus as khauj tshiab tsim mus rau Unreal cav tab thiab nyem lub pob install engine. Lwm qhov sidenote, nyem lub pob txhim kho tshuab yuav ua rau koj nruab qhov hloov tshiab ntawm Unreal Engine, lub sijhawm no nws yog Unreal Engine 4.21.2.

Kauj Ruam 2: Teeb Txoj Haujlwm

Tom qab lub Cav tau teeb tsa nws yog lub sijhawm los tsim qhov project. Unreal muaj cov qauv uas tuaj yeem siv tau tab sis kuv nyiam pib los ntawm kos, yog tias koj xav tau koj tuaj yeem siv 2d tus qauv lossis koj tuaj yeem tsim qhov haujlwm tsis muaj dab tsi, muab nws lub npe thiab cia nws thauj khoom. Nco ntsoov sab txog cov ntsiab lus pib, nws yuav tsis xav tau rau qhov kev qhia no tab sis koj tuaj yeem khaws cov ntsiab lus ntawd yog tias koj xav tau.

Kauj Ruam 3: Tau Txais Animations thiab Teeb Tus Qauv Animations

Qhov ntxiv uas peb yuav tsum tau ua yog ntshuam cov khoom muaj nqis, Kuv tau txais kuv los ntawm: https://www.kenney.nl/. Lub vev xaib no muaj cov cim thiab tilemaps, tab sis yog tias koj muaj koj tus kheej cov khoom muaj kev ywj pheej siv lawv. Muaj 2 txoj hauv kev los ntshuam cov cuab tam rau hauv Unreal Engine, txoj hauv kev rub thiab nqis, lossis koj tuaj yeem nyem ntshuam thiab ntshuam cov khoom koj xav tau. Tsis tas li kuv pom zoo tsim cov ntawv tais ceev tseg hauv lub cav los ua kom yooj yim mus nrhiav. Kuv ib txwm tsim cov ntawv tais ceev tseg rau cov cim khoom, cov duab ua kom pom thiab lub xeev suav sau, yog li ntshuam cov sprites thiab thaum koj xaiv tag nrho lawv siv "Ctrl" + "A" los xaiv tag nrho cov sprites thiab nyem txoj cai ib qho ntawm cov sprites xaiv "Sprite Actions" thiab nyem "Apply Paper 2D texture settings." Qhov teeb tsa no ua rau cov ntaub ntawv uas peb tau coj los saib zoo dua. Tom qab ntawd yog tias cov sprites tsis raug xaiv siv qhov kev tswj hwm thiab tus yuam sij los xaiv txhua daim duab dua yog nyem rau sab xis thiab nrhiav cov haujlwm sprite thiab nyem "Extract Sprites." Tom ntej no, yog qhov lom zem ua rau tsim cov tsiaj ntawv, thiab pib teeb tsa cov cim kev ua yeeb yam. Txog tam sim no cia siab rau cov animations lawv tus kheej. Kuv tsis nco qab hais tias ua ntej peb pib ua tus qauv tsim qauv yuav tsum tsim, txoj nyem rau nyem rau hauv daim phiaj txheej txheem, muaj tag nrho cov chav kawm tso tseg nyem nyem lub pob ntawd thiab ntaus hauv "Ntawv Cim." Xaiv qhov kev xaiv ntawd thiab muab lub npe txheej txheem. Kuv yuav hu kuv li "EGA player_character." Tam sim no nws tau tsim peb tuaj yeem tsim cov animations rau tus neeg ua si tus cwj pwm. Yog tias koj tab tom siv cov duab ua yeeb yaj kiab los ntawm kenney.nl cov duab thav duab tau suav ua piv txwv, yog tias muaj 2 ntas rau kev ua yeeb yaj kiab taug kev nws lub npe yuav yog "Assetname_walk_0" ntxiv rau thiab ntxiv mus. Cia peb pib nrog cov tsiaj ntawv taug kev, nrhiav pom tus kheej sprites thiab tswj nyem los xaiv lawv, tom qab ntawd nyem rau ib qho ntawm lawv thiab xaiv "Tsim Flipbook". Ua qhov no rau tus so ntawm tus sprites rau dhia thiab sprites tuag.

Kauj Ruam 4: Txheeb Xyuas Nrog Cov Tswv Yim thiab Cov Xeev Suav

Tom ntej no, Txheeb Xyuas Lub Xeev thiab tau txais cov cim txav thiab cov tswv yim teeb tsa. Kev suav sau yuav siv los khaws lub xeev ntawm cov neeg uas ua ntawv thiab yuav pab tau rau teeb tsa teeb tsa cov ntawv ua haujlwm tom qab. Txhawm rau txhawm rau tsim ib qho kev sau npe txheej txheem txoj nyem-nyem mus rau "Cov Qauv" thiab nyem "Enumeration." Qhov txuas ntxiv uas yuav tsum ua yog tsim kev suav sau rau siv hauv cov txheej txheem flipbooks ua haujlwm tom qab, tom qab ntawd peb yuav tsum tsim cov tswv yim rau cov neeg ua si. Txhawm rau ua qhov ntawd mus rau "kho kom raug" >> "Project Settings" thiab nrhiav "Engine" nyem rau ntawm lub tswv yim thiab muaj 2 daim ntawv qhia kev xaiv "Action Mapping", thiab "Axis Mapping", Axis Mapping yuav siv rau kev txav mus rau sab laug thiab sab xis, Yuav muaj ib qho Axis Mapping thiab ib qho Kev Qhia Ua, nco ntsoov qhov no yog qhov yooj yim thiab koj tuaj yeem ntxiv cov khoom ntxiv rau koj tus xeeb ceem. Thawj qhov kev txiav txim siab txhua yam koj yuav tsum tau ua yog nyem lub pob ntxiv, tom qab ntawd muab nws lub npe, Kuv yuav lub npe nws dhia, thaum koj mus teeb lub ntsiab lus tseem ceeb muaj ntau lub platform thiab cov tswj sib txawv, Kuv yuav lo nrog PC. Yog li kuv tau teeb tsa tus yuam sij rau tus xub xub thiab qhov chaw. Tom ntej yog kev ua haujlwm axis, Kuv hu nws txav mus sab xis thiab teeb nws mus rau sab xis. Tam sim no, peb tuaj yeem tsom mus rau kev suav sau, yuav muaj 2 qhov suav: taug kev, thiab dhia. Koj tuaj yeem ntxiv koj tus kheej cov lus piav qhia ntawm kev suav sau. Yog li, ntawm no yog yuav ua li cas koj ntxiv lawv nyem tshiab thiab muab cov npe sau npe thiab yog tias koj xav tau cov lus piav qhia.

Kauj Ruam 5: Teeb tsa Tus Qauv Cim

Tam sim no peb tuaj yeem nkag mus rau sab txheej txheem ntawm yam, xub teeb tsa lub hauv paus sprite los ntawm txhaj rau qhov sib xyaw ua ke thiab nrhiav qhov Chaw Flipbook xaiv thiab xaiv qhov tsis ua haujlwm uas tau tsim ua ntej. Tam sim no, peb yuav tsum tsim qee qhov kev hloov pauv, peb xav tau Boolean, Boolean lossis bool yog qhov tseeb los yog lo lus nug tsis tseeb, bool yuav qhia peb yog tias tus neeg ua si ua haujlwm raug. Kuv yuav hu nws mus rau sab xis ua raws los ntawm kab lus nug, thiab tau tsaws. Kev tsaws tsaws yuav raug siv rau kev dhia dhia ua si thiab qhov tshwm sim ntawm tsaws tom qab.

Kauj Ruam 6: Tsim Varibles

Txij ntawm no mus, Kuv xav coj los cais cais cov kev hloov pauv uas peb tsim. Ntawm sab tes xis muaj lub vaj huam sib luag nrog lub npe sib txawv, tus nqi, piv txwv tuaj yeem hloov kho (lub ntsiab lus nws yog pej xeem thiab koj puas tuaj yeem hloov nws hauv tus khoos phis tawj) thiab qeb, nyem rau hauv kab ntawv kab ntawv thiab muab pawg npe, Kuv qhia "Kev txav mus los" qhov no yuav suav nrog bool thiab kev siv rau lub xeev suav suav tshuab peb tau tsim ua ntej. Peb tseem yuav xav tsim lwm qhov kev txav chaw cuam tshuam nrog bool Kuv yuav hu ua tsaws. Tom ntej no nws yog lub sijhawm los tsom mus rau qhov hloov pauv rau cov phau ntawv flipbooks, rau cov no muaj ntau yam sib txawv hu ua Paper Flipbook, teeb tsa nws mus rau qhov khoom siv, suav sau cov phiaj xwm yog li koj tuaj yeem hloov kho qhov txawv txav, txawm li cas los xij kuv yuav tsum ceeb toom tiv thaiv kev hloov pauv ntawm boolean. hloov pauv rau qhov tseeb, nws yuav cuam tshuam qhov peb tab tom ua tom qab. Tsim kom muaj qhov ntau ntawm cov khoom sib txawv ntawm cov ntawv flipbook uas koj xav tau. Tom qab ntawd peb yuav xav tau ntxiv lub koob yees duab thiab cov khoom tiv thaiv lub caij nplooj ntoo hlav, txhawm rau ntxiv ib feem tsuas yog nyem ntxiv tivthaiv thiab tshawb nrhiav lub koob yees duab, tab sis tsis txhob hnov qab tias lub caj npab caij nplooj ntoo kuj tseem xav tau yog li nyem ntxiv cov khoom ntxiv saib sab caj npab xaiv nws. Tam sim no, nyem thiab rub lub koob yees duab, yog tias nws tsis yog menyuam yaus ntawm caj npab caij nplooj ntoo hlav ntawm caj npab caij nplooj ntoo hlav.

Kauj Ruam 7: Teeb Lub Koob Yees Duab

Tam sim no, nws yog lub sijhawm los hloov lub koob yees duab teeb tsa hauv cov lus qhia ntxaws muaj lub koob yees duab teeb tsa xaiv hauv qab lub koob yees duab teeb tsa hloov kev nkag siab mus rau orthographic thiab qhov piv piv uas ua haujlwm rau koj lub computer screen Kuv tsis zoo nrog nam piv li, tsuas yog hloov kuv li 2048, txhawm rau tiv thaiv kev tsoo lub vijtsam ces txuag thiab suav ua qhov project.

Daim ntawv sab sau cov kev txwv rau tus cim rau x, y thiab z rau kev sib hloov thiab txoj haujlwm.

Kauj Ruam 8: Hloov Hom Game

Image
Image

Qhov ntxiv uas peb yuav tsum tau ua yog hloov pauv game game settings kom ua li ntawd peb mus rau qhov kho kom raug tab thiab xaiv qhov chaw teeb tsa tom qab ntawd pom daim duab qhia chaw thiab hom nyem nyem lub hauv paus zaub los ntawm xaiv gamemode, zoo li kuv yuav xav tsim hom game tshiab yog li, yog tias koj cov kev xaiv tau greyed zoo li kuv tau nyem qhov ntxiv los ntawm lub npe ntawm hom kev xaiv game Kuv tab tom ua qhov no yog li peb tuaj yeem hloov kho tus neeg uas ua ntawv uas tsis muaj tseeb yuav siv thaum twg peb rub qhov game.

Kauj Ruam 9: Teeb tsa Flipbook Function Creation

Nws yog lub sijhawm los pib ua haujlwm ntawm kev teeb tsa tus neeg ua si cim kev txav chaw, ob npaug nyem rau daim ntawv cim tus qauv uas koj tau tsim nws yuav coj koj mus rau ib qho ntawm 2 lub qhov rai qhov teeb meem tshwm sim lossis qhov pom, yog tias koj tsis tau nyob hauv qhov teeb meem tshwm sim thiab nyob hauv qhov chaw saib nyem lub tab thib 3 (yog tias koj siv lub teeb tsa lub cav tsis raug). Koj yuav tau txais tos los ntawm lub vijtsam dawb nrog lub thawv nrog cov zaub hauv nws hu ua OnEvent BeginPlay, tsis txhob txhawj txog qhov ntawd. Hloov chaw peb tab tom teeb tsa teeb tsa phau ntawv ua haujlwm ntawm peb tus kheej.

Hauv qab cov khoom tab muaj cov haujlwm tab nyem rau ntxiv rau ntawm lub luag haujlwm tab, ntawm qhov no peb yuav tsum tsim qhov sib txawv los khaws lub xeev cov tshuab uas peb tau tsim ua ntej, lub tshuab hauv lub xeev yuav pab hloov pauv yooj yim ntawm cov duab yam tsis tas yuav siv tus qauv tsis tseeb Teeb tsa Flipbook muaj nuj nqi, ob npaug nyem rau ntawm qhov ua haujlwm tshiab thiab muaj lub npov liab nrog lub npe ntawm txoj haujlwm tshiab rau nws nyem rau nws thiab muaj qhov kev xaiv rau kev nkag mus nyem ntxiv rau ntawm cov khoom nkag tab teeb tsa qhov sib txawv los ntawm kev nyem khawm thiab hauv kab ntawv tshawb fawb ntaus lub npe ntawm qhov suav sau uas tau tsim ua ntej muaj qhov ntawd thaum pib nkag los lossis zoo li kuv ib txwm hu nws lub xeev tom ntej. Tom qab ntawd teeb tsa qhov piv txwv rau lub xeev los ntawm kev rub hauv enum qhov sib txawv los ntawm qhov sib txawv tab thiab thaum koj ua qhov ntawd nyem qhov kev xaiv teeb tsa. Tawm ntawm qhov ntawd nyem rau ntawm cov zaub ntug hauv paus thiab rub ces tso mus ntawm tus nas khawm yuav muaj cov ntawv qhia zaub mov uas tau coj los nrog kev tshawb fawb bar hom teeb tsa flipbook hauv txoj haujlwm, xaiv qhov kev xaiv ntawd, hauv qhov kev xaiv peb muaj ob peb txoj kev xaiv, xws li: lub hom phiaj uas tau txiav tawm ncaj qha rau, thiab phau ntawv tshiab, nrog qhov kev xaiv flipbook rub tawm ntawm qhov ntawd thiab tshawb nrhiav xaiv. Nrog xaiv muaj qhov ntsuas, los ntawm lub neej ntawd nws yog boolean, peb tuaj yeem hloov qhov ntawd los ntawm kev rub hauv thiab tso lub xeev lub tshuab rau hauv qhov ntsuas, uas yuav muab sijhawm rau peb siv cov phau ntawv tig peb tsim, rub thiab tso cov kev hloov pauv ntawd. rau hauv txoj haujlwm sib xws, txawm li cas los koj teeb tsa nws. Qhov kev xaiv ntawd yuav yog qhov txiav txim siab phau ntawv tom ntej. Tom qab teeb tsa flipbook daim ntawm txoj haujlwm rub tawm ntawm phau ntawv teeb tsa thiab ntaus rov qab. Kuv ua qhov no kom zoo, nws tsis tas yuav tsum tau. Qhov ntawd yog txhua yam peb xav tau rau teeb tsa phau ntawv ua haujlwm.

Kauj Ruam 10: Teeb tsa Kev Koom Tes

Tom ntej no, peb yuav tsum teeb tsa cov khoom siv txav mus los, Nkag mus rau qhov xwm txheej teeb tsa thiab nyem rau sab xis thiab tshawb nrhiav Kev Nkag Mus Kuv tau hu lub tswv yim nkag mus rau txoj cai MoveRight. Qhov xwm txheej no yuav yog peb cov lus tsa suab. Tom ntej no, tawm ntawm cov tswv yim axis rub cov xaim tawm ntawm cov zaub ntug hauv paus thiab tshawb xyuas sib piv ntab, yog tias tus nqi axis tsis tau nyob hauv cov tswv yim ua npuas rub lub axis tus nqi hlau mus rau cov npuas. Hauv kev sib piv ntab muaj 3 daim tseem ceeb, peb yuav tsis siv == feem ntawm qhov sib piv ntab. Hauv <ntu peb yuav tsum tau teeb tsa txoj cai txav mus los los ntawm kev rub qhov sib txawv los ntawm lub vaj huam sib luag mus rau qhov xwm txheej teeb tsa thiab nyem qhov teeb tsa xaiv thiab nyem rau ntawm lub npov ib zaug, qhov no yuav teeb tsa bool rau kev txav mus kom raug, rub qhov txav mus rau sab xis thiab teeb qhov ntawd rau cuav rau <, feem ntawm qhov sib piv ntab. Los ntawm qhov no rub cov xov hlau los ntawm ib qho ntawm cov kab lus teeb tsa thiab tshawb nrhiav ntxiv cov lus tawm tswv yim, coj mus rau lwm qhov teeb tsa nqe lus thiab rub nws mus rau hauv qhov ntxiv txav cov tswv yim peice ntawm cov ntawv sau, tom qab ntawd rub los ntawm cov tswv yim axis npuas mus rau ntxiv txav cov tswv yim tus nqi npuas. Nco ntsoov, Kuv pom zoo kom tawm tswv yim li no, koj yuav ua li cas yog nyem rau sab laug thiab rub hla cov cai koj xav tawm tswv yim thiab nias C.

Kauj Ruam 11: Dhia Direction thiab Kawg

Image
Image

Thaum kawg, mus rau tus tswj kev taw qhia. Qhov no yuav suav nrog kev sib piv ntab. Tsim lwm qhov xwm txheej tshwj xeeb, los ntawm qhov ntawd peb xav tau kev sib piv ntab, piv rau 0, peb yuav tsum tau txais nrawm dua, tab sis hloov chaw tsuas yog tau txais nrawm nrawm faib qhov rov qab tus nqi pin los ntawm txoj nyem thiab nyem cais cov qauv tus pin. Siv tus nqi xa rov X raws li cov tswv yim rau kev sib piv ntab nrog> thiab == mus rau qhov tseeb ntawm ceg ntoo peb yuav tsum tsim los siv kev txav mus los sib txawv nrog <thiab qhov cuav ntawm ceg ntoo mus rau teeb tsa kev tswj kev sib hloov, uas peb yuav tsum tau faib kev sib hloov ua npuas nrog tib txoj hauv kev siv los cais qhov tau txais tus pin nrawm, tom qab ntawd teeb tus Z pin rau 180.0, vim li cas txij li thaum peb tsis muaj lub hom phiaj tseem tsis tau siv lub cav yuav yws ntawm peb kom txog thaum peb pom lub hom phiaj, qhov no yog qhov peb nyem rau sab xis thiab ntaus hauv kab ntawv tshawb nrhiav kom tau txais kev tswj hwm siv tus nqi rov qab los rau teeb tsa kev tswj kev sib hloov. Qhov teeb tsa thib ob tswj kev sib hloov yuav muaj txhua yam sib npaug rau 0. Ib qho ntxiv yog dhia, qhov no yuav ntev me ntsis. Thawj qhov peb ua rau ntu no ntawm tus ua cim tau teeb tsa yog saib cov tswv yim nkag mus dhia lossis txhua yam uas koj tau txiav txim siab los hu lub pob kem ntawd, los ntawm qhov ntawd peb yuav pom tias muaj qhov nias thiab tso tawm ceg ntawm qhov nias peb tuaj yeem rub tawm los ntawm daim duab peb sab thiab tshawb nrhiav dhia, ntawm kev tso tawm peb tuaj yeem saib qhov dhia dhia. Peb tsis tau ua tiav txawm li cas los xij, txoj nyem thiab saib tuaj yeem dhia thiab siv tus nqi xa rov qab hauv ib ceg ntawm qhov xwm txheej tseeb peb xav tau hu rau peb teeb tsa phau ntawv ua haujlwm thiab ntxiv qhov ncua ntawm 0.2 vib nas this tom qab ntawv tau txais kev qhia txog cov yam ntxwv txav mus los thiab saib yog tias tus xeeb ceem poob los ntawm kev tshawb nrhiav yog ntog hauv kab tshawb fawb siv tus nqi rov qab los ntawm qhov ntawd los teeb tsa peb phau ntawv hla tebchaws mus rau lub xeev tsis ua haujlwm (txij li tus ua cim uas kuv siv tsis muaj qhov ua kom poob los ntawm qhov zoo li nws.)

Tam sim no, nws yog lub sijhawm kawg los ntsuas tus cwj pwm no hauv qhov kev ua si. Ua ntej koj sim nws txawm li cas los xij kom paub tseeb tias koj coj tus tswj kev ua yeeb yaj kiab thiab cov tswj kev coj thiab sib txuas lawv mus rau qhov tshwm sim zuam.

Pom zoo: