Unreal Engine 4 Tutorial - Splines - Moving Platforms

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello everyone and welcome back for another tutorial in Unreal Engine 4 in this episode we are going to make a start on our spline mini series where we look at splines and their many uses in this episode we're going to look at using splines to make moving platforms so here I've set up a couple examples ready so here's the lift okay and when I get off of it you're wise and we set back down below and here's a more traversal moving platform okay okay now jump off of it it will be first back thing so you can use this to make any kind moving platform it's not so difficult so let's begin so let me just first of all clear previous examples away from the map so I don't get confused and what you need to do is make a new blueprint actor so click on add new blueprint class and choose actor and you will name it nothing appropriate and open it up now this actor will have a couple of components so nickel pilot listed on the left hand side you wanna click on add component anyway first we're going to add it's a static mesh click on a static mesh component and in the right hand side you are seeing a static mesh details and here it says none from the drop-down choose a mesh that you've previously bought in I saw walked in my moving platform mesh like so the next component we going to need is a box collision so I click on add component box collision and this will act as the trigger to determine whether or not the player is on the platform and if they are on the platform we're going to move to platform so movie box on sites on top of the platform and you want to resize it so it fits better and the whole thing now an important thing to note is that your box illusion is actually a child of your static mesh so when the static mesh moves so does the box it should look like this with a static mesh here and the box down and to the right if it isn't if it looks like this then you need all you need to do is click and drag and drop it on top of the static mesh this means that the box is now a child to the static mesh and what so when it moves the box will move with it to the last component is going to be the spline so type in spline and you want the one that just says spline not spline mesh now the spline itself we don't want to be a child of the static mesh because we don't want it to move at the same time as the box as the platform so click and drag it on top of the default seen root and click attach so your final component list should look something like this with that done we're now going to go into the event graph we need to get rid of all these because I'm not gonna use any of these and we're going to use a begin overlap on the box clear trigger to do that we click on the box and then right click in the middle and go begin overlap you'll see add-on component begin overlap the first thing we need to do is check whether or not the actor that's come that is in the trigger is actually the player so with other acts are selected drag this out and you wanna cast this to the installation of third person character but this would be the name of whatever the character actor your player is playing as with that being successful we will then go off and make a timeline to type in add timeline yeah it will ask you to name the time line so on the name line move platform and double-click on it this will open up the time line allowing you to edit it and the moment it's blank so we're gonna add a couple of to add one track to it you can see you've got a float track back to track event track and color track we want the float track name your track only name mine travel distance the length up here will determine how long it takes to get from one end to the other so if you want to be a little bit different you can do you just type in whatever you want to be here for this time just leave it as five to add a point onto our graph this is a graph editor we shift click to add a point once a point is selected we can determine its time and its value in the time enter zero in the value enter zero this means it'll start at zero zero shift look again this time with time as five which is the end of the graph make value equal to one and you'll see a line now appear on the graph if you click these two buttons here this will allow you to zoom it so you can see the whole tie graph now this is what we call a linear graph meaning that it's going to increase a set amount over time it's not going to get faster or slower just a set speed I want my platform to accelerate and decelerate to do that we select both of our points which you can do by so click dragon right click and choose auto this will give it a nice curve this is an acceleration curve and a deceleration curve when we're done here we click compile and then go back to our event graph so click on the event graph tab you can now see that travel distance is now a node or a pin rather on our move platform time this is called a scalar value because it goes zero between zero and one and what we're gonna do is we can use this to determine how far along the path we are at zero I've been the start and one being the end to get that we dragged on there splines are drag spline component onto the event graph and then from spline choose get length you'll see gets blind length you want to multiply the travel distance afloat by float multiply it by the spline length this means it'll get the full value of the distance so if we our travel distance of 0 this will be 0 if we're no travel distance of 0.5 we'll get half way along the spline length which exactly what we want okay the next bit is to turn this into affecting the static mesh component so drag the static mesh component out onto the event graph and from here we're going to set world location from update on the time line connect it to that set world location and you'll be asking for a new location in the world to do that we're going to drag out from so drag another spline component in and from there we want to get location at distance along spline the distance comes from this float here now you return value will go into new location the coordinate space you want to change from local to world because this is going to set a world location not a local location we want to make this making sure we get the world coordinates from them thus Prime with that done the next step is to set its rotation so I want my mesh in my platform sorry to rotate along with the spline to do that you want to drag another static mesh onto the field onto the event graph SOI and from there you want to set relative rotation and what this means this will add on this rotation onto the current rotation that you've previously set so a new rotation comes from the spline again so from spline topping gets rotation at distance along spline and again distance is hooked into that multiplier this time we'll leave it as local and the rotation here will go into this rotation here click compile and we're gonna close and platform into our world so the waist Brian's work is that you'll see a line here this is the spline a spline so she has a line that has points that determine its shape okay so it has two points with one section and I can move grab and move these points I've got the end point here and move it these red marks are the tangents which handle the curvature of the line if I'll add more points to our line I just click the Alt key and drag it away to make a duplicate point and again I can move this I can also rotate it kind of end to our curve now it's not perfect because as you can see it's more like a flying car where it just rises up and down okay and also it doesn't return back to its flying position yet so let's fix those couple of things go back into your moving platform and the first thing we're going to do is fix the reverse so on the timeline node you actually notice it has a reverse input and the best men input so submitted begin like that we also get one again end other than that so again click on the box component right-click in the graph and you were tapping end overlap you'll see I don't opponent in overlap and we want to cast it again to a third person from other actor a check to make sure that we are actually the player and you will drag that on to reverse click compile and we will now see when I jump on to it and then jump off of it it will reverse back to its time position now notice how the rotation is a bit weird okay that's because it is rotating all the axes to follow the line okay so it's following it perfectly which is not what we want okay so from our blueprint when we got make we've got a new rotation coming from our rotation at distance we want to actually break that off and with new rotation right click on it and choose split and on your turn value right click and split and you only ones you want to hook up this time or just the Z and the X leaving wire line click compile play and you see how it keeps it it keeps it flat and rotates it round okay now one thing you may want to solve as well if I were to drag this in here and rotate it first of all and then make it do its thing you notice how it snaps moves that's because it needs to always be facing forward to match the line so to do that we're going to fix that with a begin play so right-click begin play and the static mesh you want to drag out and set relative rotation and the new rotation will count and spline subtract the spline point out and choose get rotation at distance we want distance to remain at zero Curtis to start of the line and just right click split by for these again and hook them all up from Y so at a start it's going to rotate immediately yet whichever way the line is coming so why is that up and there's your moving platform now obviously this is only working with the trigger but he wanted to be automatically moving platforms it's a very simple similar setup essentially you don't have the these begin overlap in overlap you don't need to cast it at all you just helped it begin play to move the platform so if I were to probably McKim play instead go here this will play the platform automatically start them at starting the level and you can make them loop in reverse as well as I'm making Reverse up so you've got loop here autoplay and you also got reverse investment so you can do everyone with this you can drag to finished out to activate another custom thing so I can drag out just do custom event and name it reverse reverse here and we go finished past them just do the best like say you see it goes up and then maybe the best is back down okay take your loop to sleep there unless a make it loop okay so you could do like its porting from one end to the other a conveyor belt type of thing but if you wanted to go to the end and reverse back and start again again when you watch it on reverse God finished we want to then set it back okay but you can twist you can play with and with this however you like you decided we won't do here okay and that's basically I would do for the first episode in splines and how they can be used make moving platforms in the next episode we'll start looking at how to make meshes with splines and make roads and pipes and things like that but thank you for watching and I hope to see you next time if you've liked this video and you want to see the next part of this video already you can see it right now on patreon if you want to support me and my videos and my content and my games of element you can do it over at patreon from $1 a month you can get access to videos too it's ahead of time and insight into my game development I'm doing at the moment with my own project thanks for all the support so far and see you next time bye bye I have one if you do like these videos and you have liked what I've done in the past and want to see what smell else I can do and all your support is greatly appreciated on YouTube however I do have a patreon set up as well where you can support me in further money donated by yourself will help me make better videos a better content and more frequently hopefully plus it will help me develop my own projects currently I'm in a project at the moment and I'll hopefully be able to share that with you soon if you just just choose to donate and subscribe to us on patreon you doing it access to videos two weeks ahead of time plus there are many other rewards available to you too so head on over to www.skinnygainmuscle.com [Music]
Info
Channel: Ryan Laley
Views: 48,211
Rating: undefined out of 5
Keywords: UE4, Unreal engine, Unreal, Moving Platforms, Platform, Lift, Elevator, Splines, Rotation, Location, Spline points, Timelines, Beginner, Explained, Easy
Id: -2Pxh3Dzb9o
Channel Id: undefined
Length: 18min 12sec (1092 seconds)
Published: Thu May 31 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.