‫Hello and welcome.
‫In this lecture, we're going to be setting up our own little obstacle assault course, and we're going
‫to be implementing these little pusher platforms here that will push our character off.
‫We're going to have to implement a few little fixes to our character class in order to do this.
‫So let's dive in and see what they are.
‫So another type of puzzle I'd like to include using this basic moving platform component is to have
‫a pusher that will basically push us off of a ledge.
‫Now, the way that I want to do this is take this cube here.
‫I think it's called Puzzle Cube A, and that can be the cube that is essentially the pusher.
‫And we're going to configure it slightly differently from the moving platform.
‫So let's go ahead and navigate back to our platform so I can right click and actually go click go here,
‫which takes my camera kind of to focus on it.
‫And then what we can do is go to our content, draw to the C++ classes, click my search, go to Obstacle
‫Salt, right click on the moving platform and create a new blueprint class based on it.
‫This time I'm going to call it the BP underscore pushing cube like.
‫So I'm going to put it in the route of content and click Create Blueprint Class.
‫Now I can close my content browser.
‫I'm not sure why it keeps wanting to bring that one up and I'm going to go to the content draw, go
‫to the root of content, and search for the puzzle cube or one word, and we're looking for the puzzle
‫cube.
‫Ay so that's this one here, the mesh.
‫I'm going to drag in to our blueprint class and then close the content, draw close my compile results
‫so I can see the viewport a little bit better.
‫And I actually want to scale this cube up because by default it's actually quite small.
‫I'm going to make it at least ten times bigger in every dimension.
‫So I'm going to hit a little padlock next to the scale property so that each of these basically scales
‫the same.
‫And I'm going to change one of them to ten, and then the other two will scale up to ten as well.
‫And then what I'm going to do is I'm going to change the direction of movement.
‫So it's currently moving in the X direction.
‫And if we look in our scene, you can see that that's basically the forward direction.
‫I want to move it side to side.
‫Obviously, we could rotate it once we put it in the scene and it wouldn't matter so much, but I'm
‫going to change it to zero in the X and it needs to be reasonably fast for it to be an obstacle that
‫we need to avoid.
‫So I'm going to make it 300 and I'm going to make the move distance fairly large too.
‫So going to make it at least 500 to start with.
‫And obviously this can be then configured again once we place this in the level.
‫So let's save that, go into our level and try and place this cube.
‫I'm going to cancel out my search in the content draw, go to the root of content and drag in a pushing
‫cube.
‫It's absolutely massive.
‫I definitely got the scale way off.
‫So let's go back to the Blueprint class for the push in Cube.
‫Go look at the scale property and maybe we just want to make it four times larger and note that I'm
‫doing this with this scale lock on.
‫So I'm making it four times larger in every dimension and go back into the level.
‫And this is looking a lot more reasonable now.
‫So you can see that it's actually clipping into the ground a little bit.
‫So what we can do is we could either solve this by lifting up the cube in the world, or we could do
‫it once and for all and actually lift it up in the Pushing Cube class instead.
‫So I think we're going to need to lift it up by about.
‫Let's start dragging up and see what looks sane.
‫I think about 200 puts it on the ground plane.
‫So save that and go back into our scene.
‫And there you go.
‫It looks like it is correct.
‫Now I'm just going to move it so that it's going to overlap with our player.
‫Let's go ahead and hit play and you can see it's moving backwards and forwards.
‫It's not moving very far backwards and forwards.
‫So I think we do need to change that.
‫Let's go back to the class, go to the class, defaults and make the move distance.
‫I think it's going to need to be at least 1500 like so.
‫And we might want to set the move direction in the opposite direction, although that could just be
‫a matter of preference.
‫So let's go back to our main window and drag the cube over to the left instead, because that's the
‫direction it's going to be moving in.
‫Let's hit play.
‫And there we go.
‫It's going past very slowly.
‫So I'm not happy with the speed.
‫Let's change that speed.
‫I think it needs to be at least three times fast.
‫So let's make it 900 hit play.
‫And there you go.
‫We've got a bit more of a challenge.
‫However, we've also got a bug.
‫Our character doesn't really get pushed in a very sensible or nice way by this pushing cube.
‫You can see it glitches.
‫It's not smooth.
‫However, I would like to draw your attention to a little workaround.
‫If I'm trying to move while it hits me, you notice that it actually does it all very smoothly, and
‫that is because the character code doesn't actually check for collisions unless you are trying to move.
‫So there's a little bit of a workaround for us to do this.
‫We're going to go to our BP third person character that we've created.
‫Now, the way you can get to this is either via the content draw or you can select the character in
‫the scene, go to the details pane, go to the Blueprint button and hit Open Blueprint Editor.
‫And what we want to do is essentially every single tick, we want to move the character a little bit
‫to the left and then a little bit back to the right.
‫Now, the way we're going to do this is using a component on the character called the character movement
‫component.
‫So select that in the components pane, then right click in your Blueprint Event graph and then search
‫for move updated component.
‫Essentially what this function does is it tells.
‫The movement component that it should use its character movement rules to move the character around.
‫So you can see that it takes a delta which basically says, this is how far you should move.
‫And it has a sweep, which tells us that it should look out for any collisions along the way.
‫So we can make it do a very straightforward movement of basically one centimetre in the X and Y.
‫It doesn't so much matter whether it moves in the Z because we're not looking for those collisions,
‫really.
‫Then we can take the tick and drag the execution pin into our move.
‫Updated components.
‫And if we left it like this, it would be problematic because gradually our character would be drifting.
‫Let me show you if I hit play.
‫You can see that the character is gradually one centimetre at a frame at a time, is drifting his way
‫across the scene.
‫So what we need to do is also move back.
‫So dragging a character movement component down here, I'm going to drag off of this pin again and look
‫again for the move.
‫Updated components.
‫I'm going to thread in the execution pin so that it gets called after the first move updated component.
‫And then I'm going to make the delta minus one in the X and minus one in the Y.
‫So the end result will be that nothing seems to have happened, however, because we've forced the movement
‫component to look for these collisions with the sweep, it's going to react smoothly to the pusher.
‫So let's go ahead and hit play and go and stand in the path of our pusher.
‫And you can see we very smoothly get nudged just out of the way, like so.
‫So I'd like to challenge you to make an obstacle course of your own using this pusher and moving platform
‫components that we've put together here.
‫So here's the example of the obstacle course that I've made in my prototype.
‫You can see I've got some moving platforms to raise me up onto a little island so you can use one of
‫these islands and scale it down as a platform.
‫And then I've got the pushers moving backwards and forwards that I have to make my way through.
‫And then there's rotating platforms, but we're going to get to that later.
‫So don't worry.
‫But we've got these pushers and we've got the moving platforms, so have a go.
‫You can try and replicate this, or if you're feeling creative and want to try something different,
‫then please go ahead and create your own obstacle course because that's always really exciting to see.
‫And if you do create something unique, please share it in the discussions so that we can all have a
‫look and get inspired.
‫So pause the video and have a go.
‫Okay.
‫Welcome back.
‫So now that we've got our pushers working, let's make something a bit interesting, shall we?
‫So I'm going to take this platform and actually rotate it around.
‫So we've got a bit more length to our to our setup, and I'm going to drag it along.
‫So the character is right at the end of the platform, and then I'm going to take these two moving platforms
‫and position them one after the other.
‫And one of them, I'm going to add 1000 to its Z axis and I'm going to send it moving in the opposite
‫direction.
‫So these two platforms should meet somewhere around the middle.
‫Then I'm going to duplicate the floating island that we're standing on.
‫So by alt clicking and dragging, I'm going to rotate it just so it doesn't immediately look obviously
‫the same platform and I drag it out and I'm going to rescale it a little bit so that we can fit it on
‫top of the other platform.
‫Because ultimately what I want to happen is that once we get on top of this upper platform, we get
‫pushed down so we don't die.
‫But it gives us a bit of a setback.
‫Now, I'm going to take these pusher cubes.
‫I'm going to actually just drag them in on to the upper platform.
‫I'm going to put a few of them in.
‫So I think three is enough for the time being, and I'm going to drag one of them over to the other
‫side and flip its velocity like so.
‫So instead of being nine, it's going to be -900 and we're going to go in the opposite direction.
‫Let's try this out so I can get up onto these moving platforms.
‫They allow me to have a bit of a ladder up here and now I have to try and get past these guys.
‫And interestingly, I just noticed a little bit of a bug with the way that we're forcing our character
‫to move and will cover that in just a second.
‫But yeah, it's a little bit challenging, but it is doable.
‫We could definitely get through those.
‫I'm not doing it very well at the moment, but we could definitely get through those cubes if we wanted
‫to.
‫So the next thing to do is fix that little bug.
‫Now the issue here is that when we called move updated component, we're setting a rotation in here
‫that is not our character's rotation, which means that it's always going to put us facing forwards.
‫So the easy way to fix this is to right click and do get actor rotation and simply pass the actor rotation
‫in to the new rotation four Move Updated Component.
‫You can pass it in to both of them, but the one that really matters is that we'd be doing it for the
‫last one so we can go ahead and play now and we should be able to see that we can indeed now rotate
‫our character as appropriate.
‫Well, great stuff.
‫In this lecture we have fixed a little bit of a collision bug with our character and we've set up a
‫little bit of an obstacle assault course for us to get started.
‫I hope you've had fun and I'll see you in the next lecture.