How to Move a Character Along a Spline in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome to new Unreal Engine 5 tutorial today I'm going to show you on how to move a character along and explain it's gonna be a very easy beautiful so let's get started alright so the first thing I want to do is go into the content browser right click and create a new blueprint class this will be an actor and let's just call this BP underscore spline you know whatever you want to call it let's go ahead and open this up so here what we need to do is add a new component and this will be the spline component under utility just go ahead and hit enter for now we are not going to change anything on here we're going to leave it as it is uh but now we're going to do is select the default scene root and add a scale to mesh which will be of course our character itself now it doesn't need to be on the spline it can just be like in his mentioned attach it in just the blueprint itself okay under scene boot it doesn't need to be under display so now selecting character we can just go ahead and find our for example Queen money Queen simple sorry like that and then we just go ahead and put this minus 89 so it's standing there now the normal thing will be also to minus 90 here so it's facing forward but the thing is that actually all this will be upgrading and while we move it along this plane so this values will really just be for our previous so it's a bit nicer honestly okay um so with that said we can just go into the event graph I'm going to delete the big gameplay and actor bigger number lap I'm gonna stay with the event tick as you may know it basically is basically ticked every frame so it's always ticking all right so in here what we want to do is get our Delta seconds and multiply by this by a parameter and this will be our speed I think that the character will move around this plane so just right click remote variable let's go ahead and do the spline speed whatever you want to call it right and now make sure to compile select the supply and speed and put it an initial value for example 300 and with that what we're going to do is go ahead and get this and add it into another value in this case just right click and this will be our distance along spline so basically this is the current distance that our character will be inside our spline and with that we can now go and set it with our new value there we go so now basically we'll have the new distance now of course we have our new distance but we have to set it to our character so let's go ahead and just get it and I'm going to do is call this set relative transform node active Transformer there we go let's put this here now what we need to do is just right click the transform and split it so now we have the location rotation and scale separate and then we'll need to do is go ahead and get our spline and this this node which is the um get transform uh distance alarms explain we just plug out distance here and set this to local is right click split it again so now we can just plug our location and rotation here and leave our transform as it is one or you can just get the character and get the relative relative scale 3D tool right so just plug it in just in case you change it here so also automatically will change here so basically we're keeping the the size the same but applying a location and rotation so with that you will see that actually our you know characters should move I want to explain now let's go ahead and quickly just Mark the speed as with the eye icon so it will be public so we can change it once in here so let's drag it into the scene and you will see that it's here so let me just put a bit up so it's like bad I only put it back here and now can you select my spline and holding alt I can just drag it and then it will create this new scene here so I can just click click this to rotate it to hold alt drag it here I'm over here click this like this so it's rotating like this and I can just go ahead and do it one more time like this out on here click this and more like this will be with that rotation curve there we go um so now if I hit play it will simulate basically so my player doesn't spawn you can see that my character is moving like I wanted now you can see that there's a problem and it is that it isn't facing the way that is basically going this is what I explained for about this which is operating so I wanted to do is basically just go ahead and get the rotation and basically disconnected so hold alt click it right click and split it do the same in here right click split so now we have the individual axis separately so we can just get the Z and then add minus 90 or subtract 19. just add minus 19 and just drag it into the cell now the X and Y will keep the same but now with the location we need to do the same thing so hold alt and click split right click split a lot of numbers and notes here but now let's get our X and Y here but the same with this just add in this case is minus 89 and just plug that into the Z and now with that um it should be placed correctly so now you can see it is perfectly rotating and seeing forward and also in the floor so everything is great now let's add the functionality of uh completing the the spline and also looping okay so right now you might select my spline I can go and select the spline component and Mark closed loop this will go ahead and just complete the loop as you can see so I can go ahead and repeat but right now if I for example set the speed to 700 so it's a quick test you can see my character will go through the spline but when it gets into the end it will stop so let's go ahead and add the phones on the functionality of looping so just add a new variable and let's say it's Loop and will be a Boolean of course so it's true or false and basically in each frame we'll just ask if it will look if so we're gonna go ahead and make sure that our current distance along this plane is greater than our spline length okay so length over here if so it will mean that well it has finished the loop because it has gone more than the spline distance if so we want to do is just get the distance and you set it back to zero because it will be placed at the beginning but because it is the same distance pretty much the same point there's not another translation or whatever so now you can see that it will go through all my spline and now when it gets to the end of course I forgot to enable the can Loop so just click the I compile go here and then Loop enabled now yes once again click play and you will see how this spline well the guy that goes to the spline and there we go it's in a loop and we go through now last step here in this video will be animating the character so to animate our character we're just gonna go into this plane and because it is always moving we can just go and set the in the character the animation to be an asset and just have the Run animation and this will be just the uh yes whatever and now you can see now it will be moving along this plane there we go I've also set the speed to 600 so it's bit matching battery run animation and you can see that it will go ahead and go in a loop so that's it guys if you found it so helpful I will show you guys video And subscribe to my channel everything is lagging right now um yeah go ahead and join my Instagram server and now yes with all I said bye foreign [Music]
Info
Channel: Gorka Games
Views: 41,115
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5 spline move character, tutorial, quixel, megascans, unreal engine move character through spline, spline move tutorial ue5, ue5 character move spline tutorial, ue5 travel with spline tutorial, how to make a character follow the spline path in unreal, unreal engine 5 how to use splines
Id: jjvPoTSTjsw
Channel Id: undefined
Length: 8min 3sec (483 seconds)
Published: Wed May 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.