‫Hello and welcome.
‫In this lecture, we're going to be looking at how we can get the rotation of our camera and apply that
‫to the spawned projectiles.
‫So as I rotate my camera around, you can see the projectiles are being rotated in the same direction.
‫So you'll notice that there is a rotation that we can put in to our projectile.
‫Now, this may be the start of helping us rotate the direction of travel of that projectile.
‫We can use the we can use some information from the projectile later on to actually set our impulse
‫in the correct direction.
‫However, it's currently really hard to tell which way our projectile is rotated because it's entirely
‫spherical.
‫So let's open up the BP projectile class and go to our static measure component and go up right to the
‫top where it has the transform scale property.
‫And let's just increase the scale along the X direction.
‫A value of about two should do the trick.
‫You can see that it becomes this kind of deformed sphere instead.
‫And if we go ahead and play and shoot this sphere, you can see that the direction that it's traveling
‫in is pretty much the, you know, that's that's the direction of the sphere.
‫And so we can see whether our rotation is having any effect when we spawn it.
‫So let's go over to the level blueprint.
‫And the most logical thing to do would be to say, okay, let's go ahead and get the rotation of the
‫player pawn.
‫So let's drag off the player pawn reference node that comes out of get play a pawn and let's look for
‫rotation.
‫And sure enough we can use get active rotation that seems to match with get active location, it returns
‫a rotator.
‫So this seems to fit and we can drag that in to our spawn transform rotation pin of this born actor
‫node.
‫But if we go ahead and play this and we shoot off in different directions, you will actually notice
‫that basically the projectile is not rotating at all.
‫Now, the reason for this is that if we go in and hit play and then instantly eject, so using F eight
‫and have a look at our pawn, we can have a look at the pawns rotation in the details pane so we can
‫click on the pawn, go to the details pane, have a look at the Transform Rotation property and you
‫can see that it's rotated 180 degrees about the Z axis, but that's the only rotation we've got there.
‫So what happens if I repossess the pawn, which I can do from the toolbar right at the top there is
‫a little controller button or I can hit F eight to jump back into the pawn shoes.
‫What happens if I rotate 180 degrees round?
‫I would expect my rotation to reflect that.
‫So I hit F8 again.
‫I jump out and select the default pawn and I have a look at its details pane, but you can see it's
‫rotation hasn't updated and that's because by default the this default pawn in unreal isn't configured
‫to rotate with the camera rotation.
‫Those are two separate things.
‫For whatever reason, it doesn't particularly matter.
‫But what is important is that there is something that does reflect that rotation and that is called
‫the control rotation.
‫So you can drag off of the get player pawn node and you can search for control rotation instead.
‫And you can see there is a get control rotation node.
‫So I'd like to challenge you to try that node out, try the control rotation, replace the get active
‫rotation node and plug in to the spawn node and see whether it has any effect.
‫When you play in the game, do those projectiles point in a different direction?
‫Pause a video and have it go?
‫Okay.
‫Welcome back.
‫So let's delete our get active rotation, pull off of the get player -- node and search for get control
‫rotation and bring that node in.
‫And you can see the output is again a rotator.
‫Hopefully this time the value will be correct, however.
‫So let's get that rotator and connect it up to our input for the spawn actor.
‫We can go ahead and hit play and now if I change the way I'm looking, you can see that these projectiles
‫are flying off a little bit sideways now.
‫They're not traveling in the direction of their rotation that we're going to sort out in the upcoming
‫lectures.
‫But this is a first step.
‫We now know what that direction should be.
‫I'll see you in the next lecture.