Create mobile game in unreal engine 4 tutorial, Endless runner tutorial for beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello there i'm sarfanzi and welcome in this tutorial where i will show you how to go from something like that to something like this yeah pretty much how to create endless runner for your mobile phone whether it is android or iphone doesn't matter completely from scratch and right here without anything i will show you where to get your resources where to get assets so if you want you can end with exact same result as i have well let's get to it we will start on mixamo because first of all you need to get some character with animations and you don't want to make it yourself so for that you will use mixamo which is website from adobe where you can choose some characters from here and animate them you can of course also upload your own character to download from elsewhere or create yourself if you are brave enough but here i'm not going to waste time with that and let's let's put here this motion capture guy use this character all right so now when we have character let's go to animations and we'll have to choose some so for our endless drama we need i believe three animations but first of all we need to run so and you know what let's let's act professionally and adhere this narrow to run because there is nothing better than in order to run and let's put it in in place make sure that you enable this in place it will be much easier to set up so once you have it click on download everything leave as it is which means fbx with skin and 30 frames per second download it alright and we also will need to have him just standing there as idle character before he will start running so let's find some idol and let's say that he will be happily idol because it's better to be happy idle than just idle you know what i mean so let's take it and download it as well and this time around you don't need to have a skin rivet it will just download skeleton with animations and you can set it to use mesh that we have downloaded before so let's download it and we also will need some kind of jump let's see for example jumping just jumping no that's not gonna work we need something where he was just stayed in place let's actually go with jump with this beautiful lady because right here we can set it to in place right now it looks kind of weird but trust me it will look pretty good let's download it again without skin you can also see that it's pretty small file if you are downloading it without skin alright that should be about all character assets we need now so let's go to library in your epic game launcher we will need to create new project for it let's launch your version of unreal engine it probably doesn't matter what version we are using i'm on for 25.4 and we are going to create new game and that game will be third person character right here click next leave it to blueprints and we are going to develop for mobile and tablet and we don't want any starter content and just to be sure maximum quality switch to scalable 3d or 2d and probably don't do retracing unless you have some phone from nasa in that case not sure what you are watching here anyway let's also rename our project for example something like press the like button and subscribe to channel all right that's probably not a good game but you should do it nevertheless let's delete this one and call it endless runner mobile and you can see that we have some problem name of project cannot contain spaces so let's put here under scrolls but you probably don't need to worry about that because we are currently pressing the like button let's create the project now when you have new project let's import here our character so let's right click and create here a new folder that folder will be called character and because we will have only one character let's just leave it like that and i personally prefer to click on this icon because it's easier to orient it this tree structure so let's click on character and then get your downloaded files and first of all you need to import your fbx file with mesh if you are goldfish and don't remember which was with mesh you can simply look at size of it the one with mesh will be much bigger which means it's this run so let's put it here import and make sure that skeletal mesh and import mesh is enabled because we need to create new skeleton and also make sure that you enable import animations because we also want our run animation click on import all all right you can see that it shows some errors but you can probably ignore that if you want to quick fix for that you need to use t0s when you are importing it but it probably doesn't matter you can check it if you click on this animation and see that it works pretty well and the problem was that skeleton from mixamo is a bit different than skeleton that unreal engine i like to use there is also a way to fix it you can import it all in blender and then export it for unreal engine i have actually a tutorial for that so link in the description and this eye somewhere so if you want to see that you can but let's continue with this tutorial right now it's compiling shaders because this character has already applied all these materials so let it compile and import the rest of the animations now you can select all of them and put it here by all of them i mean these two of course and make sure that your skeleton the skeleton is set to run skeleton and animation exported time blah blah that's all fine let's import all and now if you look at it you can see that our animations are good and well can put it in the game if you click on this arrow next to play button you can select simulate and he should be dancing and he even has a textures congratulations guys we got this wonderful actor in our game to make it a little bit organized let's create a new folder that will be called materials and take all the materials and textures and put them in it move it here so now the next thing will be to actually use this character because first of all i will show you how to program all the logic for your game and then switch character and do visual stuff to make it actually look nice so let's click again on this arrow and put it on selected viewport that will start your game and you can see that you can control the character that person going from anywhere you want but that's not exactly how you play endless runner so we will need to change it quite a lot let's escape from it click on your personal character and right here on the right side edit third person character from now on i will go fairly fast so if you don't understand something and your complete beginner or something like that don't hesitate to ask in comments or join the discord it's much more likely that i or someone on discord will see your question and will try to help you there so link in the description and now let's actually get to it you will need to find logic for moving and moving input seems about right that's exactly what we want but right now it works only if you press button before going forward which means w on your keyboard so let's actually do it all that we don't want to go right we don't want to go left nothing like that so we will just take this delete input axis move forward and find here event tick so right click and put here event kick all right it created new one that means it wasn't used before in this project and let's start by just connecting it here let's see what it does compile event you basically do all the logic after it every single frame of the game that's why it is quite expensive so don't use it for too much stuff let's click on play and he's running and i can stop it wonderful that's what i wanted i can still jump but i can go left and right but it will go forever forward let's say that it works way too fast for now so for that we'll create a new variable for this scale value right now it's set to 1 and we will have to change it so right click on it and promote it to variable let's call it speed and by default it's set to zero set to one let's set it to 0.5 by default which will be probably pretty slow but because yeah you can see that it's very slow you can also see that i can still move my camera so let's do something about it if you don't want to click always on that character and right click you can find it in content browser and third person bp blueprints and here it is third person character it's a name of it let's set speed to 0.8 and if you also wonder why i've turned it into variable that's simply because i want to be able to speed it up later so let's say that after five minutes of playing you want you would want to have speed to be much faster than on the start of the game and now let's do something with the turning of camera here we have mouse input that's something we don't want we don't want to be able to turn camera so let's delete it compile and now now i can't even use my camera i can still jump but that's about it the problem now is that every time you run forward you run right into this wall so the logical answer for that would be to simply delete that wall but now you just fall down into abyss so let's create some corridor or floor that will let you run let's do it in third person vp and blueprint we will just save here all our blueprints so let's right click blueprints and set it just to actor we will call it corridor all right double click on it and first of all let's put here cube just i got a cube and because it should be floor let's scale it down on z axis make sure that this lock is unlocked and put it down let's go with 0.1 and always put it in the game so we have some idea how big it actually is and now you can see that it's pretty small so let's say that we wanted to have 10 times 10 [Music] it will be actually pretty big to be honest let's try six by ten and that's uh that's starting to look about right i would probably make it even longer i would go with eight times sixteen that looks about right if you put it somewhere here you can let it run and you can see that it's running forward forward but once it ends it of course he of course dies which is something we will have to fix first of all we will have to take this cube and move it so it starts somewhere around here pretty much on a place where you could have seen this white ball that indicates start of this blueprint now we will add here component that component will be collision box collision scale it up and because we are just testing it all now let's make sure that we see it in the game let's scroll down and set the rendering to hidden game disable it so now you will be able to see it in the game and it's weirdly it's not on the center why is that right let's make sure it covers all of it all right so now next thing will be to adhere arrow because we need some component that will indicate us its position you can see that position 0 0 0 is approximately here on the start but we need to put this arrow on the end of our corridor so i believe that we set it to 16 so it should be 600 let's try it if i all right now that um the problem is that i'm scaling you should set location x to 600 let's see oh it looks about right yeah and now let's pretend to be organized and call that arrow under scroll pawn location and and the cube let's call it floor box collision let's leave it as box collision we don't need to overdo it so much but we will actually for 50 box collision now let's scroll down and click on on component backing overlap create cast to third person character casting is basically asking the other character if he can do something for you you want to connect it to other actor so once player will overlap with this collision something will happen and that something should be creating new blueprint so from this corridor we will create new corridor right on this position and because we are starting this on position 0 0 0 it should spawn it on the end of it let's take it from this cast and we'll spawn actor from class that actor will be of course our corridor and spawn transform let's use this arrow that's why we have it here with such a long useless name from that you will get wall transform and connect it here so now let's actually test it we'll move it move it a little bit closer so it's easier to go for it and see what it does all right that looks pretty cool look at that every time our player will run through that collision it will spawn next corridor next piece of corridor so he will never run out of it if you want to look at deepak camera you will probably need to go into project setting and set and setup shortcut for that because i'm not sure what is by default i have it as asterix and you can see that it's all it's pawning next and one next one and next one now let's create touch control so you can actually control it with your finger once you put it in your phone all right again let's go into that personal character and somewhere here should be you know what let's delete gamepad input and vr setting we won't need any of that we will need this touch input sadly enough all this is pretty much useless for us so let's delete it and what we will have to do is first of all create hidden new variables so let's go down here on the left and create here new variable and the variable should be touch underscore start and make sure that you change variable type to vector 2d right here and now let's duplicate it and simply rename it to touch and make sure that you compile so you can work with these variables and let's look at this input touch what it does it always notices that you touched your screen and where it is but now we also need to make sure that engine knows when if you are swiped left right or up down etc so after you press it we will need to set our touch start and we also need to save where it was so let's take this location and break vector because we are using only x and y axis it will be pretty weird if you use z-axis on your phone right click on this touch screen and split structure pin then connect x and y and actually before we are pressing it we will make sure that we have reference for knowing that it is happening so we'll create a new variable that variable should should be is pressing switch it to boolean take is pressing from here and make sure that you click on this execution pin and we'll set it to true and now we will need to create new custom event so again right click and put here because add custom event that custom event should be called check swipe ping and now we want to make sure that it's checking swiping pretty much every frame so click on the 7 gig move it back a little bit and put here sequence so we can adhere another branch from there let's put in actual branch and as that condition we will use is pressing if it's true we'll call that custom event so check swiping so every kick of the game it will ask if it should check swiping but it will check them only after you put your finger on screen or just interact with in with it in any way all right let's move check swiping somewhere here so first of all after check swiping we will need to add another branch because we need to check how much you have actually moved your finger but before we will check it we need to also set our variables for touch end take touch end and set it here connect it to released and again you can use same location okay of course you need to split structure pin and you can use same x and y location it actually is not same location that that location has changed because this action is on the release that location is different hopefully then on press so these are different coordinates even though they are going from same note simply because they were shot at different time let's go back to this branch and we will take our touch start get start get touch end and subtract them from each other we'll go vector 2d minus vector2d from it we will have to take vectorland to see what is an actual value in float vector2d length and to see if it's bigger than something i would do about 300 that's basically how big difference it must be before your touch start to touch end to notice it is swipe you can play with this value to find something just right for you so after it makes sure that it actually is swipe a fire from here do once and because if it stayed like that it would really do it only one or you could swipe to only once in your whole game let's connect this reset always here so after every release it will reset it and you can keep swiping now we will actually set touch end again and you don't need to take it from here you can just copy it here let's ctrl c ctrl v connect it let's add here get player controller and from it let's take input touch state why do i have a caps lock make sure that it's on touch one because this one works with touch one as well you can check it here the secret value is set to touch one and now let's take that x value and y value so from now we will need to run bunch of branches to figure out which directions that swipe went so let's start with branch and let's take here touch start get touch start and touch end which has possibly different value that it had before because we have set it here again and again set touch start minus vector touch end break vector 2d set about to absolute value absolute float and that endless condition we need to set it to float bigger than flow so let's set it here and connect absorb for x here and absolute for y here from that let's run another branch take x value make sure that it's bigger than zero connect it here again and if x value here is bigger than zero then it should be left so let's let's actually put here just a comment click c and put here left you can print here string or something but this is this will do for now and if it's false it should be right these are just commands for us so we know which one we should be used for what and then we will continue with this branch if it's false let's duplicate this one and connect it with y and put here another branch again right here and here if i is bigger than zero it should be up and if it's false it should be down all right that should be it look at that let's actually comment it all so we know what's happening here let's select notes that you want to comment and click see this one is check if it's touching check if it is touching right now let's take all these move them down comment it all and call it determine swipe and this one should be just check if it should be swiping you can comment it however you want just make sure that you actually know what that code was about because we all know that time where we programmed something and then came later to it probably even that day and have no idea what happened there so comment comment everything guys it's much better than not commenting so now when we have touch control working we can actually set up here some moving let's find some empty space for example here and create a new custom events just add custom event and let's call it move left and what we will do here is take our capsule component and also just to make sure that we know what is actually happening click on that capsule component and disable this hidden in-game so right now if you run the game you will be able to see that component it can come pretty handy take that capsule component and add local offset let's do actually add vault offset and if you are not sure which location it should be you can just find your character somewhere here and you have here your transform arrows that you can see and you need you see that i am moving my green which means y axis and think about that so let's say plus 300 let's say about plus 300 that should be fine so why on the left should be probably minus 300 you can switch that later i'm probably wrong not gonna lie and create a new custom event that should be move right and just again duplicate it you can connect same capsule component and set it to plus 300 and now we will call these custom events from here so let's go here in the branch touch control and after left we will call move left and after right obviously move right and we also have function for jumping so after up we will call jump no not a stop jumping exact opposite of it actually start jumping jump nice but now it of course wouldn't work if you played it you can't do anything because your mouse doesn't work so we'll need to go to edit project setting and in search details put here mouse and use mouse for touch that will let you use your mouse as if it was a finger on your touch screen all right so now you have here your mouse and you have also these touch pads we will get rid of them later but now you can see that if i move it and i have to move it a lot to make it happen so we will need to change the threshold let's go into third person character it was right here okay right here and let's put here actually another command how much swipe and let's change it to 100 maybe even more all up to you play and now you can see that if i okay that wasn't my best idea if you can see that if i move it just a bit it works just fine and it's jumping in between that all right let's set up switching between lines we already have this movement but you can see that it would be switching a bit too much so let's fix that so first of all we need to adjust our game map let's delete everything at least here and we will need to make sure that our character is set to location on y-axis as zero and let's delete this weird thing and make sure that corridor is as well set to zero so when you start your character will be running right in the middle on zero coordinates if you switch it to left he will be on minus 300 and if you switch it to right he will be in plus 100 which is exactly what we will use if you want to get rid of these shadows you need to rebake lighting so click on build build lighting and build right lighting only setting is set to preview and while the lighting is building we can get rid of the joystick we had on screen so let's click on edit project setting and let's try right here touch yeah we're here we go we got mobile always touch in always show touch interface is disabled but we have default set to this thing so we will simply clear it and that should help us have nothing that okay i have hit lightning build completed which you cannot see because of my face you are welcome by the way click on apply now and it's all gone but now if you click play you can see that we don't have here any joystick and touch control you can you can use just your mouse so now let's limit our movement to the left and right click on third person character and we here we have our move left and move right right here move it forward a bit and set up here branch we will start in move left and we simply will need to take our capsule component and get its location so get world location right let's take from our condition float equal to float here we go equal float and from our get board location we will split structure pin and take it only y value so how to see which one should be which is pretty simple if you look at if you click on your character and move it to the left you can see that on left side it's minus 300 and on the right side it's plus 300 so let's make sure it's again on zero and now when you want to move left it will first of all check if it is equal to minus 300 if it is equal to it you won't do anything but if it's not that means it's on 0 or plus 300 you will move to you will execute it and move your actor to -300 and we can simply replicate it right here ctrl c ctrl v and the other thing will change is to set this to plus 300 and again make sure that it's connected as false not true because it's if it's true it won't do anything but if it's false it will work click on play and you can see it doesn't matter how much i move it it doesn't work and i can switch only between these three lines with this simple code that's quite nice actually let's put here some comments so we know what that's what's up here we'll move it up okay take all of it press c call it movement and and then take these two ctrl c again and put here limit movement by the way if this is already a bit too messy for you you can click on your limit movement and change its color to let's say red or something like that then you will have quite a nice color palette right here and let's do the same things with these actually switch it to blue okay this is the weirdest blue i've ever seen in my life but doesn't matter and we will change one side to them the next thing we should do is to adhere camera because look at that our camera is moving again with us which doesn't look at all how it is in a regular endless runner and it was in it is also quite close etcetera etcetera so we will have to get rid of it and for that we will need to create new actor new blueprint actor call it camera under scroll pp i should have done this before but i it's much better if you put different shortcuts for different assets in your game so corridor should be again corridor under scroll bp like blueprint then click on your camera and let's create here camera right compile it and go into event graph we will need to create here event and let's add here local offset add actor local offset which is pretty much very similar to what we have in our third person character as add movement input but we don't have here function for character movement so we have to do something like this we will need to get forward vector so let's get forward vector and now we can just connect it here in delta location we need to multiply it with something so let's set it vector times float and this value we need to set as speeds so we need to set it to same value as it was under personal character so let's put it variable and call it speed underscore cam then in that person's character and we have speed and let's rename it to under scroll here like character and by default we have it to write compile by default we have it to 0.8 so let's see if we can set it on same value here all right but now let's put it in the game so take our camera put it on the same coordinates as our player which means y must be zero fold it up and make sure that you don't rotate it otherwise your vector wouldn't work your forward vector wouldn't work and it would go somewhere to hell so if you want to rotate it well you know what we will do with that later first of all let's make sure that we switch our camera view to this new camera so click on your third person character and right here we will need event beginplay and first of all we need to call for reductor so let's do act uh that relates to casting and in this case it will be get actor of glass that actor of class is of course our camera camera beam and now what we'll need to do is to get player character oh no get player controller i believe and we will set camera set view target with plan connect it to execution pin and then new target view right here let's click on play and see what it does and you can see that our camera switched but it seems like our character is running way too fast well that means our camera is moving way too slow let's see where the problem is all right all right well it's just pretty simple even though i'm not quite sure why is it like this well in camera pp you cannot put it in our speed of cam on 0.8 you need to put it into eight just move it to the left i'll just add zero as you would and on player character leave it like that as 0.8 which is quite strange actually i'm not sure why it is like that but now if you click on play you can see that everything is just fine but now we need to adjust the size of that camera so let's move it a little bit closer down and as i said you cannot rotate it here if you want to rotate it you need to go open your camera bp and rotate it down right here now if you click on play it looks just nice oh well that camera is way too close right now so let's move it on it's set to minus 20 right now on y axis so let's do minus 12 that could be cool and maybe i would actually change perspective if you want to edit it in real time you can click on that camera which is this one and adjust it here see maybe something like 75 that's way too close all right i will leave that to you you can play with it and make it just perfect but now you can see that i can move my character camera is not moving with it everything is cool but what i can actually do is to make it a bit nicer and adhere that camera blend for that i will actually click on our third person character and change this camera so it's much closer you need to click on camera boom and switch it to like 20 no all right that's way too much let's switch it to 15. if you look in the game it's okay that's way too close let's do 100 and make it look so it's looking at him from behind something like that bit glow a bit lower that's cool so we will start with this camera but then with our camera blend right here let's comment it c change camera looking look at blend time that's how long that blend towards this camera will take we will change it to two seconds which is actually pretty long maybe it should be lower so now when you click on play it will start in your original camera and slowly go to your new camera which looks quite cool actually and you could have seen that jump and drop on that so let's just lower it just make sure that it's pretty much on the same z coordinates as floor now it shouldn't be that aggressive yeah now it's pretty smooth make sure that you have this collision high enough so you can jump over it i would maybe put that camera a little bit more behind so you can see a whole body when he will be jumping something like that yeah look at that that's pretty cool you still can see full body but you got the idea all right so now we have smooth transition of camera we have sort of a game and we don't have anything that can kill us and that is never a good game there where nothing can kill you so let's adhere some obstacles we will need to create for the new blueprint blueprint actram that should be called obstacle again i forgot obstacle bp obstacle under scroll b beam let's open it and we'll just add here cube cube sounds about cute if you know what i mean that was terrible i'm sorry now let's go in to corridor b beam and we will add here's and we will let it spawn somewhere here so on eventbeginplay which means once this will be spawned we will create actor from class no no no action it sends it's actually actually spawned spawn actor from class oh yeah and you shouldn't compile before you connect it because it will give you this error and we need to choose where it should be alright so now we need to find reference for where to spawn it let's add here new row it should be arrow under scroll obstacle under scroll zero one make sure that y is set to zero and x should be you know what x actually doesn't matter let's set x to 200 and y is to zero and z move a little bit up so it should be pretty much on the start of this mesh okay compile now let's duplicate it obstacle 2 set it y to 300 then duplicate it again and set it to y minus 300 so we have all three lines and then i will probably move it bit forward let's set x to 500 but it doesn't really matter it's just a reference so now you would go to event graph we can actually do it even on construction script but it doesn't really matter right now so let's power up stick on and from these we will make array make a name click here add pin and add pin connect all three of them from that array we will get a copy that copy will be a random integer because we always every time it will spawn we want it to pick a random one so let's put here a random integer in the range 2 which means it that means it will choose one of these frame and from here we want to click on the spawn transform split structure pin rotation and vector should be the same that's all right but from our arrow we'll get world location split structure pin and again split structure pin on location once more and we will take our c connected and our y and connect it so it will take random y and z coordinates from here but for x we want it to be anywhere on this space so let's put here a random integer so random float in range what we will do it differently i'm sorry we just will need to change it a little bit we will take our x from here set it to plus load plus float connect it here and right here we'll connect our random float in range so it will take x location from here and add some value to it and let's say that from it's it will start on 500 to 1000 which means that you can add from 100 to 500 units 100 to 500 units and then select it here the difference is that right now it will use this location which means location of that arrow and then add something to it wow it seems that it's quite cool now let's speed that guy up a little bit our camera will run away but it doesn't matter now i just need to test it so click on speed character and set it to 10 oh come on 30 to 10 so it will run super fast and you can see that it's well now it's stopped wonderful and our camera is trying to catch it but it's all right that's because we have now the synchronized speed we are just testing if it's spawning random obstacles which it seems it does so let's change it quickly to 0.8 again all right this is bit too easy as you can see so what we will do and we will create another obstacle on this space so let's go into okay we need to go back into corridor bpm and in viewport it's bubbling few of them here let's take all of them move it back then duplicate it and 4 to 6 move right here forward a bit then in constructions and now in event graph we will take this and change the random float to something lower so it doesn't cross this these two and we will actually switch these two functions so right click and collapse it to function that function should be where are you there you go left on functions spawn obstacles move it all up and now we just want to repeat it and right here we won't spawn from one two two no what is the problem we got from one two three oh yes one two three we will need to take four to six connect it right here and that should be fine look at that now we have more obstacles the other problem is that our obstacles are spawning bit too low that's simply because if you take this cube you could see that in the middle of it is this thing which is center of its coordinate zero zero zero and we need to start on it let's start like that and do one more actually thing we can change its scale on our construction script because right now every every time it has the same coordinates so you could just jump over it and it would be super easy to do so let's say that i want to go into construction script take that cube and change scale set the world scale 3d connect it and by default statement which one is it a z should be changed of course it's z what am i thinking about x should be one y should be one um you need to split it before and then for z we'll use random float in range and that will be from 0.8 to 2 or 2.5 let's say so now if you click on play you can see that they have always different scale on z axis some of them are small so you can jump over them but this one should be pretty hard to jump over okay i still do that but it's slowed our camera which is quite large because next time once you will touch it it will actually kill you so for that you will add your collision on component back in obstacle bp add here collision make sure that it's under a cube because we want it to change if we change scale of this cube so what's up what's up what are you lagging so much oh of course the problem is with construction script because it's trying to edit them in real time i while i'm editing it which makes it probably go kind of nuts so let's switch it out look look scale and scale it up make sure that it covers all of it all right put in construction script connect now it should be fine see works just fine and right now and the only thing we will do here is once this box collision will on component begin overlap with our character cast to third person character which is our player pawn we will we won't do anything but we'll just prepare something for it let's add a new custom event and call it dead and we'll cast it all right so before we set up deadlocks actually start to work on visual side of our game and add here newborn new character they have imported before so we created folder character let's put it here where is my run oh here run was changed with materials that's pretty bad let's move it back in characters and first of all we need to click on that skeletal mesh and preview some animations just to make sure that everything is cool seems like it is and that's just me being paranoid to be honest but you will get used to it once you develop enough and we'll need to first of all create animation blueprint so let's add here let's right click put animations and animation blueprint our skeleton will be run skeleton you should rename it to name of your character and underscore skeleton but do you want to mess with that right now this should be just character underscore anime open it right click and create new state machine connect it right here and first will be new state that should be run slash let's put it just on the run you know what we will start with run connect here run animation in state machine just connect it right here and let's also set up here jump so click here on event blueprint update animation here on left and we will need to of course cast to third person character because that's the one we'll be using with it connect it from casting let's take is falling from character movement and this will give us boolean that we can promote the variable and the variable should be is jumping or just is falling doesn't really matter connect it here and now back in new state machine right click new one new state call it jump if you open it put here our jump animation and let's add here arrows first one should connect to is jumping i know if i need to do it bit differently let's see equal equal boolean if it's true do jumping if it's not true on our arrow back it's not jumping and then let's go to that person vp that personal character i will need to change it so click on that skeletal mesh and switch it to run and as an animal to need to be use animation blueprint and our animation blueprint should be of course newly created character animation vp and you can see that he's already running if i jump he is actually jumping with me look at that that looks kind of weird not gonna hide but i can see that those animations don't look as nice as i would like to so you can actually probably do something about that if you click back on character character animb then in here in these transitions you can make longer this time of interpolation right here in duration let's switch it into jumping to something actually shorter 0.5 and on your time on your way back let's try 0.5 so 0.05 and 0.5 let's see okay that that looks that looks still kind of weird so probably use different animations that i'm using but that's what you gotta use with it you can see that animation ended before he manages to fall down so you would have to change the animation or make it longer you can probably make animation play longer if you click on this jump play animation player rates it to do a little bit slower 0.7 let's say it would look like it would be in slow motion but it looks much better than it did before and that's what counts so now we have our new character so let's make sure that he can die yes and let's also move it closer this camera so it's more realistic yeah something like that that's cool he's jumping way too high if you want to limit the way he jumps open third person character and in character movement let's hear max step high no no character when jumping falling jump z velocity right here it's on 600 what's default by the way 450 420 let's set it to 300 he won't jump too much but it will do the trick see if it will be something just really super low it will work or maybe a little bit more as i said you need to find your perfect values for your game design it's always bit different and that's that will work for me even though he probably now won't be able to jump over anything oh he did that one so now let's make sure that he can die for that we will need our obstacles viewport and after box i believe that we have already done that right yep we have casting and calling out that first of all we will need to stop our camera so let's go into camera bpm open it right here and right now it's going on event gig so we'll put here branch promoted variables the variable should be is moving and by default it's set to true so compile make sure it is true and if it's true it will move but if we stop after that we will get actor of class and find our camera camera under scroll bp and we'll take the variable which means set is moving and set it to false so our camera will stop you need to set is moving to false obviously you just just sometimes it doesn't work here sometimes you know don't ask me why and now we can see it is still pretending to run but camera stopped that's cool because now we will actually even kill him so pick interpersonal character after our death which if you don't remember is called from this obstacle after it will overlap with your player it will cast to it and call that we will actually stop movement now we'll disable movement and do something pretty funny with it let's set collisions and a belt on our mesh that collision preset sets to collisions enabled query and physics now take that mesh and set all bodies below physics blend weight set all bodies simulate physics now another reset just set simulate physics set it to new simulate and connect and then again from mesh set all bodies physics blend weight app that should be it and set physics bandwidth to one connect it and let me show you what it does once you actually run into it boom yeah he's completely like dead it killed him look at how look at his legs he's not even human anymore let's see if we can make it a bit more realistic click on character physics asset here you can see it it's pretty much same thing let's try to make him a bit more realistic select all of it regenerate it and maybe this probably is not a good idea for mobile game but if you want to have it realistic you can set it to single coix convex hull and there is simulated but again and this will get you probably the most realistic way how to deal with human body why am i what am i teaching you to cut but honestly don't do this for mobile game it can be quite expensive i will stop it just just to be sure switch it back in capsules and regenerate all right but one more thing we can do in third person character edit and we don't need to go all the way let's set it to 0.75 so it won't completely simulate everything and see okay that looks much more realistic all right that looks pretty still but and that animation is still playing which is not really good we can stop it we can we can add here new animation of that so no you know what leave it leave it to one i'm not gonna deal with it right now you can add here different animations and play with it you can add animations of that so he won't this will stop moving overall and etcetera etcetera etcetera you can also add a new camera and again switch to the camera in the same way that i showed you with this camera and make some camera circling around him or something like that it can look quite cool especially on game on mobile game alright so now let's make sure that your game looks nice and for that we will use mega scans because if you are unreal engine user you have access for free to library of more than almost 4 400 000 or 14 000 sorry 14 000 assets that you can use at your disposal which are textures materials models etc etc you just need to download it and log in with your epic account i will give you a link in the description all right for that we will use this app which is called which is from quick so called bread which you can also see its plugin here right in engine magazines and it will help us put again put these assets right in the game let's look at this unfinished building collection and let's say that i want to some of these to put in my game so for example these pillars looks look quite cool so i just want to look at download setting i wouldn't use text resolution to kill right it has to be 2k then i will show you later how to make it smaller in engine and let's download some lots 4 that's 700 triangles for each it should be alright for mobile game generally if you are making game for low end system like mobile games or vr it's better to have as little triangles as possibly with still having it look nice and as material preset let's set under form and download it right it will download in the background so let's find few more stuff for example these materials looks quite cool smooth concrete wall that we can come handy again set it to unreal blah blah everything is cool and it's material so you don't need to change any triangles because it doesn't have any download it and let's also find some some obstacles that we will have to jump over and these bulk bags looks just like something i would look for but this time i'm definitely gonna use lot five because three thousand triangles for each would be kinda overkill that would be like a really big alright again unreal and let's maybe find a few more assets let's see what we can do with these stairs maybe we will be able to put them in game and make our player run on it one thousand that's that's quite a lot of triangles so be careful when you are using something from here high-end mobiles will do do it without a problem but if you want to make game that is playable on every single phone with android 7 6 you will have probably need to think about this let's adhere some rocks for example oh you know bricks bricks are better than rocks let's take only lot 7 and download it again all right you can see most of them have been already downloaded so what i can do now is to put them in the engine so let's click on that concrete pillar and on this little arrow export it to unreal probably won't work because i when i will need to change my oh it has been exported successfully let's look at that and look at that it's already all right i'm surprised i actually expected we don't have to change our way but it's already here well that's actually cool i'm surprised a bit seems like they have been they improved i i don't even have updated lightest version but if you had a problem with that for exports i think you needed to change x project location which i didn't have to do right now it found it automatically with my my open version of unreal but if you had problem with that look here but that's pretty cool it did by itself so let's export all of these i probably will have to go one on one so i i will probably have to go one by one so i will import it all in the engine and see then all right so it created few new folders here we will go here in mega scans and start with surfaces because i have two one is for wall and one is for floor so first of all let's open our corridor and put here our material put it on site and let's put here our old concrete oh come on hold concrete material see how it looks not bad not too bad right but as i said these are 2k textures which mobiles can handle but you can't have too many of them so if you just open it you can right click somewhere here and textures i believe so if you want to limit that you will have to click on each of these textures for example this one uh click on this compression will probably have it is closed so click on this arrow and you here you have maximum texture size and right now it's set to zero that means it doesn't have maximum size let's say that you want to have just 2124 so now the game and it will be displayed it will have only 124px per 124 pixels but you would have to do it for each of these maps so i'm not going to bother with that if you have problems with performance probably deal with that first textures are generally what causes most problems unless you have like 1000 things on geek etc etc generally art assets are the most expensive for mobile games right now let's take this corridor and i would add here some stuffs to make it look like actual corridor all right so i have created here sort of a corridor looks pretty cheap but it will work so now we will need to do something with these obstacles because they don't look quite nice so let's go into to do third person blueprints obstacle bp and we'll have to first of all let's disable this construction script and change this cube to different static mesh and we have here a few new stuff for example this ah they have such a weird name that i can't can't really see what they are actually right let's switch it back and move it come on you will have to move that collision of course down something like that so now if you click on play you will always have here something like that but will you you won't be able to jump over it so we'll probably actually have to increase the amount of jump because even though character is above it the important thing is this capsule that's why i showed you i let you to set it and not hidden in games so you can actually see where the problem is so let's actually change that jumping to something much higher jump c velocity to 600 again all right i didn't have to change it before i got it now let's also adhere some of these pillars so right here we'll add another arrows so hello under scroll pillar you know what now let's not call it pillar let's call it arrow rubbish and again create few of them so first of all move this one again duplicate let's put it let's say here how did i yeah i did duplicate it why don't i see it here yeah they are a bit too low you need to set z to 10 again all right you don't have to use that many arrows there are different ways how to solve this but i personally prefer to use arrows alright compile and now in construction script this time let's add mesh add static mesh component and compile it its relative transform should be some of these so again we will have we will make an array from it all right get a copy and as you would guess random integer in range 0 to 2 from that get relative transform you probably don't need to change anything here and let's set it to error so let's set it to that pillar so oh i know it's not called pillar i wish it would be called pillar so in mega scans all right i'm recording for too long not gonna lie 3d assets um concrete pillar i believe yeah here we go and it's called like this why the hell not here you go and you can see that it's switching them between these two so if you play it will be always somewhere and the good thing is that you can't run into it let's make it bigger and because we are using corridors from these arrows we just need to scale arrows so right click scale this up and maybe even more on z axis something like that and now it should be fine all right let's actually add that floor on top of it as well so duplicate it and put it up there ah we need to change uh we need to change that pillar with all of these arrows sorry make sure that that scale is same so copy it here and i don't do rubbish just paste all right so now that scale is same in all of these and now if you play it will be probably a bit dark but you can add here lights or something like that now you can see that he didn't make it he died he's somewhere there you can look at him you probably would really need to adhere some camera that will follow him which should be really simple so i will leave that in your capable hands all right and let's make it a bit more visually pleasing and adhere some of these bricks now when we have imported them in that corridor we will add static mesh just static mesh call it brick compile and put one here then duplicate it break two [Music] put it here again duplicate it and put one somewhere here so it will be close to the pillar and now make sure that you save your game because what i will do now tends to crash the engine it's not that it's hard it just tends to crash the engine it's feeded back i feel like i'm saying it in every tutorial all right open creator again and in our construction script we'll take these bricks and set them you know what let's actually let's simplify it i can make array just because it's easier for after it will do for loop for each loop so it will execute it for each of these bricks connect it here and for each of these elements we want to set mesh for our static mesh compile and add mesh let's promote to variable call it break list compile save everything again i'm paranoid but i have a reason to be again encourager now you can deselect it and here if you click on your breaklist click here right up and switch it to array compile and engine will crash that's good so right now in this default value we will add here different bricks so again let's put it on the side and with 3d assets you can see that we have here a few different bricks we have there is five of them so let's oh wait one one two three four five six okay there is six of them my bad i i don't know why i counted zero for some reason that's probably professional deformation it's coming to you too alright so let's add here six different and connect them all here and so now we have that list saved here in bricklist so from that we will get a copy and we want a random integer nope a random integer in range and ranges from zero to five so you have six different variants of what could happen now if you click on play you should have here different bricks and they are not here why is that all right it wasn't spawning but it actually was spawning but bricks are a bit too low so you will need to select all of these bricks and just move them up so they are actually here on the all right now they are in the air so now they should be on the floor about that let's scale them up you know this will be quite unrealistic but whatever this is a game we don't need to be realistic and you can see that it always change them and you should probably do better if you also change its location so i won't probably do that now because you can you don't already know how to do it so you can change its location in the same way as with this pillar and if you do and or you can hear in construction script add location to it or do something with that now if you play it you can see that you've got these bricks here you can jump over it blah blah blah you can also see that from here i can see where that corridor is ending you can simply either make the corridor longer or from the start you can spawn two of them and then always found a dirt one alright and as quick bonus let's also sometimes adhere these stairs first of all if you look at it it has yellow collision premium 0 that means it doesn't have any collisions but we can quickly fix that if you open it and look at simple collisions it doesn't have any so you can simply right click on the add 18 simplified collisions and it created something alright that looks terrible you can also put here this auto convex collisions tool which i have already here if you apply it it will create much more realistic ones so now if you put it in the game right now it will just stop you with just a test that it has a collision so you can see that he stepped up a little bit so it does have collisions what we can do here is to go in blueprints and right now we are spawning a corridor bp and i want to actually duplicate it and create here corridor with stairs still bp and this time i don't want to have this any pillars so let's what am i setting pillars all rubbish i believe is pillars and i also don't want to have it any bricks to be honest i don't want to have here any of these so i can delete all these arrows oh no you you can already delete obstacle and spawn of course you need to delete only arrow rubbish and arrow brick and possibly don't delete floor like i just did what i want to do is to add here static mesh call it stairs 0 1 because i want to have two of them and let's set it to these stairs uh what are you so concrete stairs right here and you can see i do have to rotate it about 90 degrees on oh now what am i doing of course it's 90 degrees on the axis and let's say that you move it here then duplicate it again rotate it on z axis about -19 should work and let's move it a little bit more forward and in between we can add just some box so duplicate it you can call it status free doesn't really matter let's put here this cube we just need some collisions that will stand in between that so you don't fall when you run over it and as material let's say that okay not dead one concrete pillar concrete pillar for example does does look pretty bad but you know what it is just to show you how it can look so i will let you play with that and then i will adhere scene component and make sure that stairs one two three will be okay first of all you need to detach scene component and then take stair one two three and connect it under that so now if you move steam component all of them will move as well and we will use that to switch these sites so in construction script we will take the scene component set its wallet location and before that it will take its word location so get roller location split structure pin again split structure pane and now it's just randomly throwing them anywhere as you would expect well not then randomly throwing them it's on zero zero zero what am i talking about anymore and z should be the same let's set y to same thing i don't want to really do it to move and x should be what i do the same thing we used before so we will take its location set it to plus and plus something in range so float in range from but pretty much from zero to let's go with 300 and connect it into x all right that's not moving too much let's go to 800 all right so now when we have it here we can simply need to make sure that once it will be spawning next one in these corridors uh what is it so once our character overlaps this one it will spawn corridor bp so we will do completely same thing here promote this to variable compile save everything promote to array okay close it delete and disconnect here prefer to be sure then click on that variable gonna convert it to array i didn't have even one crash today that's that's weird that's that's kind of strange you can call it corridor list and here we have we will have only two so one should be our corridor bp and other one should be corridor with come on corridor with stairs so every time you will have corner with star it will only spawn corridor bp but if you have corridor bp it can spawn either corridor bp or corridor with stairs so let's take our corridor list get correlated get a copy and random integer in range zero to one because we have only two of them if you want to add more variation to it you can create as many characters as you want and do something like that so let's try to connect it class here and see if it all works and you can see that right there is choreographed styles so let's see if our player will run to it and he runs on it congratulations guys that's pretty that's already much better than most games on the market like let's be real come on guys we already did it we already made it gamers why did i say gamers i'm too much of a youtuber now so now let's create menu and start and end of the game so we will have to create new widgets so right click user interface widget blueprint and call it menu open it and we'll just add here a few buttons scale it up put text in it that should be start here in text block and after you will click on it on on clicked it will do something but before that change it in our third person character so first of all we have our event begin time and on that we will actually pause game well before that we'll create widget which is the one we have just added menu add it to viewport add to viewport connect it right here and then let's pause our game so nothing actually happens set game post and set it to true alright and once you have it let's go into menu and after we click on that button set game paused and we won't set it to true it will be untrue again and you can play so you click on play you can see everything is standing we got our start if i click on it everything starts to work but our start is still here and stuff and you can also see that our camera is way closer for some reason so we'll probably have to move that camera back then something like this should be fine let's get back to menu and add in another one right click on it duplicate it change it to end compile and after someone clicks on it on clicked let's set it to create game so if you click on it and game will end and we also need you can already see that it's flying everywhere on the screen you need to change anchor points if that happens put it on center right here on center as well now it looks nice and let's actually put here some image you can put here image of your game or anything make sure that it's under it so the order set to zero and the order of buttons set to let's go with one and the other but two also to one all right make sure that it covers everything i don't have any pictures i could put there so let's just gonna change let's just change its color so something like that it's not centered again anchor point center click on play start and you can see that it doesn't disappear we will need to deal with that right so after you click on your button let's delete our widgets remove all widgets compile it should work start and look at that dude guys you have to say that this looks quite vulnerable this desert is the like like alright so now let's do some optimalization to make sure it will work on your phone first thing you should do is to check these textures and possibly don't scale them set maximum texture size right here so you should probably go into project setting and one of the quickest thing is to change it to forward shading enable it right here i wouldn't do it because it will have to reshade it will have to reload all the shaders which i definitely don't want to do right now so you can click it here other thing that can really help is blueprint navigation so if you put here blueprint navigation this method and change it to inclusive that should speed up your game a bit because it will take all your blueprint and convert them to c plus plus which is much faster you can simply take a command which you also need to set up shortcut for in your project or i believe engine setting and for me it's uh f11 but i have no idea it what is it by default and put here stat gpu and look at that once you start your game and it will tell you that it's possibly the problem you can see that there is some post processing that can be happening but it has only 0.2 you should have everything here under 16 if you want it to run on mobiles well see 16 is spread as pretty much 60 frames per second so you can probably go with a little bit lower about try to stay in the trench the other thing you can do is to also right now if you don't want to launch it right now on phone because you can connect your phone through usb cable and launch it and test it all on it which is probably the best way to how to do it you can also test it right here if you click on editor preferences there should be play and right here you can set it to you can switch this which will switch it to a landscape or portrait orientation and this will probably work on our portrait so now if you have to enable it you have to click on this new editor window it probably won't show you this mouse but click new new editor window you can see that images looks quite different than on the white screen logically this doesn't really mean that that's how it will look on your phone so it's definitely better to have your phone connected and always play test on that you can see if i click here i can test it like this it looks a bit more like it okay that was funny like it will in the regular phone but still have it connected like really guys you have phone don't tell me that you don't you are probably watching on the phone come on comment if you are watching on the phone the another the other thing is that you should probably get rid of light source this regular one because it's directional light which isn't really good you are probably much better off if you put just some simple movable light it's weird but movable light is still usually less expensive than this light source and put it in front of the player let's test it put here light spotlight and from above the player something like that yeah if you if we are going for a horror this could look pretty cool let's look at that deal it's ours i know i know what it does and now if you play you can see it looks much more horror like with light you can generally change a lot of stuff and that's about it i'm glad that you followed it until here because let's be real this was super long tutorial but i believe that it was worth it i believe that in this tutorial i've showed you so much stuff that you can just start putting your games out there and they will be pretty good at this type of now it's all on your design if it was helpful for you i would really appreciate if you press the like button subscribe and all this stuff and you can join the discord there is quite a good community there and we are all sharing ideas help each other etcetera etcetera i'm moving it sorry that's about it sir fancy out good luck you will need
Info
Channel: Sir Fansi
Views: 118,634
Rating: undefined out of 5
Keywords: endless runner tutorial ue4, unreal engine android game tutorial, unreal engine mobile game tutorial, unreal engine 4 mobile game tutorial, unreal engine mobile games, unreal engine mobile game development, unreal android game tutorial, unreal android game development, unreal engine beginner tutorial, unreal mobile game tutorial, ue4 mobile game tutorial, unreal engine mobile, unreal engine mobile game, ue4 mobile game, unreal engine 4 tutorial, unreal engine
Id: HFtQ7yix1-U
Channel Id: undefined
Length: 82min 33sec (4953 seconds)
Published: Wed Nov 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.