How to Make a Swimming System in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome to new Unreal Engine fact tutorial and today I'm going to show you how to make a swimming system for your player it's going to be a very easy tutorial to follow so let's get started alright so the first thing that we're going to do is just enable a plugin for the water of course you already have a level with your own water you can use that one but I'm gonna use this one uh so just go ahead enable the plugin you'll say okay it's experimental and just restart the editor so once we have the plugin enabled just go ahead and create a new level I'm just going to create a basic and just create it I'm gonna get rid of the floor and let's go ahead and create a landscape because it's required for this um you know water uh plugin to work and it's very important that we enable edit layers because the I also deposit plugin works with different layers on the plugin uh the Landscapes right and I think this size is great so just click create and just go back into the select mode now we have our landscape so let's just go here and to quickly add to the part go to our classes type in water and we have our water Body Ocean just drag it into your scene and there we go we have our water Body Ocean here now I'm gonna just select the different splines and make it much smaller because it's right now absolutely huge so let's just go here all right now I have a really small island so if I were to press play I just have my player but of course when we go into the water we of course cannot swim so let's make that we can actually go ahead and start swimming okay so let's start building the uh you know functionality so our player can swim so let's go into the third person the character blueprint or whatever you know character blueprint you're using so let's go ahead and open it let's open it just go into the events graph and basically we're gonna create two custom events that we are later going to call from um our water okay so just right click custom event and it's gonna be start swimming and the other one because some events gonna be stopped swimming Okay so I'll start swimming what we're going to do is get our character movement components just drag it over here and we're gonna get the physics volume because right from here sorry here we can set the water volume which will basically give us the functionality of being on water basically okay then I'm going to create a new variable and I'm going to say it's string and basically it's going to be type Boolean make sure and just drag it on set it and of course it's going to be set to true and then uh for now it's going to be good for us um so and the next thing I'm going to do is just exactly copy all this and you space over here drag it into the stop streaming butt invert so it will be basically disabled and disabled so oh this will be swimming and gonna make it a bit bigger because this is gonna be start and this is gonna be or stop swimming so we have it other thing so good organized it's very important to have everything organized for a large scale product or even a small bread okay so now I think that we have to do is in our movement right now if we started swimming we would just move still like if we were in a third person game mode but much slower and will not be sinking so uh we just have to make sure that we're swimming in the direction that we are facing with the camera even upward and downward so I just go ahead drag from here and make a branch and then we are just gonna ask if we are swimming so we're gonna get it and so we're gonna get this into false there we go and then I'm gonna copy and paste this and this is gonna be on true so if we are swimming if we are not swimming gonna be like normal and we are swimming we can get the accessibility and plug it in scale value and the volt direction is going to be um so here get a control rotation and then it's gonna be the get forward vector and literally just plug it into what direction now I'm just gonna move it a bit down so we have some more space and it doesn't look so ugly we did it so beautiful with our swimming display over here so just plug it over here somewhere like this and there we go compile and save so of course now um if we press play nothing happens when we get to the water because we done uh we aren't calling this function whenever we are in the water so just for testing purposes I'm gonna say that when we start I'm gonna start swimming just to go ahead and show you how it will basically look so I will go and press play you can see that basically I will be going in the direction that I'm swimming and yeah it will basically kind of look like this but of course we haven't got the swimming animations so now it looks really really weird and strange um so now let's make that basically when we get into the water we will actually start swimming okay so you select our water Body Ocean I'm gonna go in here where it says add in details panel so actually sorry in the just the button right next to it just like a blueprint icon click on it and then this will appear so we can create a blueprint from this selection just look like this and new subclasses and with water by the ocean selected and the location and name is great so just click select okay it's the only thing that we have to do so it basically created a blueprint with the object so the only thing that we have to touch is go into the event graph and gonna get rid of the advantage and begin play and we just have to touch the event actor begin overlap and the event actor and and overlap here we go so uh oh director we're gonna cast to our third person character blueprint and we are just going to um call the start swimming over here and I'm gonna copy this paste over here plug in the other actor plug this on here and on the end overlap it's gonna be stop swimming basically there we go and now we can compile and Save so I can also get rid of the beginning play on here because of course at the start we're going to be walking as normal so over press play and basically going ahead and working is working normal but when I go into the ocean it was in a second that I'm basically swimming now but of course there was some really strange things happening first of all I had to jump to be able to um be swimming then I was sliding a lot and I'm still sliding when I stopped um and then also um if I get close to the you know the terrain and these legs actually are you know the food taike is still being applied on water and then of course we have our animations to be placed so uh to fix all these things just go I'm gonna be step by step facing all these things just go into a third person character blueprint and in the character movement component uh just search for swimming and now we do have some cool things over here first of all the max swim speed that was good uh but what we're going to touch is the breaking this deceleration swimming so we're gonna place this into a big number as 500. we're gonna test uh which is going to be the best value for us and that was the thing that basically was making this slider so if I now go here at the jump I will fix that in a second but now it actually stops pretty faster you can see now it's a bit much better okay another thing fixed now this thing uh let's face that we don't have to jump when we get into the water so just go ahead and just before we enable the water volume everything on the start streaming just add a bunch character node and I'm gonna go ahead and just move sorry I'm gonna move the physics volume character movement use it to the side over here and basically the velocity is gonna be the get actor location sorry get actor rotation there you go because I want to get the up Vector and then basically I'm going to multiply this by a module to make it jump but at a very small value um so I'm just going to convert this right click convert pin to float because we are already in the up Vector and just put like a three just two and then just plug it in into launch so let's do compound save and then go here press play and then if I get to the water he will just be swimming with the same set transition great and then also we haven't test this but uh we'll fix the footer key in a second I have animation but when I get over to the water I go back running so there we go and uh let's continue with the applying animations and get rid of the put ik system so to do this we're going to do is just go into the content go into characters and just go into mannequins and animations now you can see that we have two blueprints uh we're gonna go into the ABP menu which is just the paint of the i1 now let's go quickly into the anime graph and we're gonna go ahead and disable the control rig right for now as this is for the purpose of the tutorial I'm not gonna go in the setting up that we have a certain values for control rig when we're swimming or not just to make it simple if you want to uh do it uh just leave me a comments saying Hey I want to do this and I will just respond to you okay uh how you can basically activate and deactivate your control rig but for now for the case I'm just gonna plug in the default slot so now basically you will see that if I start streaming you'll see that um the the foot are not aligning now so it isn't looking very weird when we are nearly on that place okay so now let's go ahead and place the streaming animations so I have got a very cool package um with over like 2 000 animations which is pretty crazy I will be linking it in the description now it's basically this one it's just a normal generic streaming animation for the mannequin now um I'll be living in the description like I said so you want to get there get tip uh there you go so basically I have to it so just right click retie it and I just have to convert it into the from the ue4 to the UEFI money okay because right now we've only for skeleton and there we go I have my animation here with the uh with the mannequin so great so now what we have to do is right click go into animation uh blend space 1D okay and just select the SK mannequin and yes it's gonna be the streaming space go ahead and open it so this will allow us to have an horizontal axis and as the speed increases will have different animations so uh this is going to be just speed and the maximum value is going to be our maximum value for the swimming so in this case it was 300 so just place your 300 there we go so I will get the swimming animation which is a tree this one yeah so I I guess it's just this one because I had lots of one is testing which one was the best one and then this one is gonna be at the end now unfortunately I haven't found an Edo animation on this pack which is weird because it has over dug 2 000 animations but it's okay so I'm just gonna go ahead and duplicate this animation and name and just swimming Ito and I'm just gonna do like a Live Hack and use the right scale but I like Point um points one or something so it's gonna be like if if it's like slower or something yeah he's for the purpose of this video because I don't have assuming edible animation okay so go back into the plant space and get the Ito animation to be oh sorry where's the blend space uh let's just go back here there we go get the eagle there we go and you can see now how the speed increases it changes now we've had the Ito animation the proper one it will actually be much better but it's okay so now they have the blend space set up we can go back into our many uh blueprint animation blueprint and we can click on main states down here we have basically all the well we have all these states Locomotion for land for the jumping Etc so we can just add here a new date and it's going to be streaming and literally just make a reference to plug this into Locomotion and then plug it back into swimming so we have to create a new variable which is is streaming which is going to be a Boolean 2 and basically just click on the front Locomotion to swimming and just drag it over here so when it's true it will transition and then on the zoom into Locomotion on the back one uh it's gonna be when I'm gonna get it and it's gonna be one is not Boolean so when swimming it's not we're gonna transition back basically now we need to get that uh set it from the uh the swimming variable from the third person blueprint from this one so to do this we just can go into the uh animation blueprint it's going to event graph and on here what we can do is cast into a therapist because I hear you just cast into the generic character so I'm just gonna copy this and basic cast to third person character plug it in over here there we go and um yes in the initialize animation which is just the begin play basically on the start and then on the sequence on the update animation I'm just gonna get the um this one so we're gonna right click promote to variable and it's gonna like this so basically it's now stored in a variable so I can now call it over here and it's just gonna be and get a swimming it's streaming there we go and now get the instrument animation from here from the one that I created earlier and then just plug it in over here in the new sequence and there we go now it will be basically reference and ready so if I were to go ahead and press play and I am around into the ocean you can see that nothing is happening and that's because we have to do more things go Mainstays and double click on streaming because now we haven't set up the Blanche space animations being here so just in the as a browser just drag it over here and plug it in now it's really cool because we already have the uh essential movement data we have the ground speed over here that was created earlier for The Locomotion stuff so now we went to place play We're you know uh it's going normal as we would but when we go into the water you can see that we're really swimming and now we are actually we can go up and down another thing and it's really cool and when we stop it's gonna slower but of course evil is better if we got a new animation and now when we go out of the water we go back into normal now there's a really small thing that I'm gonna do and instead you realize that I had to go a lot out of the water in order to make it um go back into normal this is just because the capsule is too big so because the animation is he's like laid down you know what I mean so uh with introducing the capture component said capsule half height and then basically over here plug it in now right now over here in the details we can see that capsule have height is 90. well let's just put something as 20 and I'll just copy all these two things and then over here I'm gonna place it back into 90 where we go out to the washer now we compound safe and then we go ahead and press play you can see the new water normally but when we get into the water we have an arrow which is infinite Loop now basically what is happening explain me why this is actually happening but we're gonna just disable update overlaps and that will do the trick now we're basically working normal but when I get into the water you're gonna see that there was something will happen and it's not because I think I went too far on the on the height so let's put it on something as 50. um so now if we go back up here all right let's play now we are playing normally but when we go into the water we now go ahead and start in swimming and now we can go up and down everything it's really cool but then when we go ahead and get out you will see that it will not take so much time to get out of the water there we go so you guys that was the tutorial if you found it useful and helpful I really appreciate it if you like the video and subscribe I have lots of Unreal Engine pop tutorials as this one so if you want to check that out go ahead and check my channel out see yeah that's it guys leave a comment another I'm notified tutorials you want to see and now yes with all that said bye bye [Music]
Info
Channel: Gorka Games
Views: 41,415
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5, swimming, tutorial, quixel, megascans, unreal engine tutorial, how to make swimming system, ue5 swimming, ue5 how to make swimming system, unreal engine swimming, unreal engine 5 how to make player swim, unreal engine 5 simple swimming, unreal engine diving, unreal engine 5 swimming simple system, unreal engine 4 swimming, unreal engine 4, ue4, unreal engine 5 how to make simple swim
Id: 0UFRpnNb5So
Channel Id: undefined
Length: 17min 46sec (1066 seconds)
Published: Sat Oct 01 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.