‫Hello and welcome.
‫In this lecture, we're going to be making our very own scene component for the grabber, and we're
‫going to print out its rotation so that we can see that it is indeed attached to the camera and the
‫camera's rotation is affecting its rotation.
‫Let's dive in and see how this works.
‫Now, if you remember from seeing the demo, I would like to have a little statue in one of these cells
‫and to allow us to pick it up and take it over to this alcove for placement.
‫Now, the problem here is that I don't have that statue and I don't have a way of even knowing if I
‫am pointing at it when I'm trying to pick it up.
‫So that is what we're going to aim to try and solve in the next few lectures.
‫So first of all, let's put a statue in place for us to use.
‫So I'm going to open the cell door a little bit.
‫So let's click on one of these cells and I'm going to go down to the door and I'm just going to rotate
‫it nicely open so that we can get in.
‫The next thing I'm going to do is it's very dark in here, so I'm going to put a new spotlight here.
‫So let's go to the quickly add button, go to lights and find a spotlight and drag that in to our scene
‫and drag it up the wall a little bit so that basically we are alerting the player to the fact that they're,
‫hey, there's something of interest over in this corner that you might want to pay attention to.
‫And we're going to go to the select the medieval dungeon folder and search for statue.
‫And you can see we've got a golden one and we've got a stone one.
‫I'm going to go for actually probably the gargoyle here and I need to give it some sort of something
‫at the bottom, because I know that this mesh has has a hole in its bottom.
‫So if we go and turn it upside down, it's going to look awful because it doesn't actually have a back
‫side.
‫So what I'm going to do is I'm going to take this gargoyle and I'm going to turn it well, I'm going
‫to actually add a mesh underneath it.
‫So we're going to look for some dirt mesh.
‫And you can see I've got a little bit of dirt here that I'm going to just take and slap on to the existing
‫gargoyle statue actor.
‫So this dirt mound and you can see it's absolutely huge in comparison, but don't worry, we can fix
‫that with a little bit of scale tool.
‫So this dirt mound, so I'm going to go ahead and scale this locked in the details pane.
‫Perhaps I'll start with 0.1 and see how small that is.
‫And let's actually rotate the entire gargoyle actor so that we can see properly what we're doing.
‫So have a look at that dirt mound.
‫The dirt mound needs rotating by 180 degrees.
‫And then let's use the scale tool to make it a little bit bigger.
‫I'm just gonna finesse these figures a little bit using the details pane now I'm squashing it right
‫flat with the scale in the Z and finessed it.
‫I think just enough that it looks like there's a bottom to that.
‫And now we can put this gargoyle rotated 90 degrees again and try and place it somewhere in the corner
‫under this spotlight.
‫So that's the aim for us to get hold of this mesh.
‫But how are we going to do it?
‫We're going to need a special component in order to do this, and we could use an actor component,
‫but in this case, it's actually going to make more sense to use a scene component.
‫Let's see y let's go ahead and go to the root of our content folder, clear out the search and open
‫up our BP player and let's open up the full blueprint editor.
‫And what we want to do is essentially to have something that tracks around when we're moving our first
‫person camera.
‫So as I play in here, you can see that I am looking all around and my camera is also looking all around.
‫So what I want is something that points in the same direction as my camera.
‫So the logical thing is to attach a component to this camera which would allow it to automatically rotate
‫with that first person camera and always be pointing, always having its forward vector pointing in
‫the forward direction of the camera.
‫So that's what we're going to do, and that is exactly where we need a scene component, a component
‫that can attach to other scene components and has a transform, has a location, rotation and scale.
‫So the way we're going to do this is we're going to go to the add button in the components.
‫But we could do this another way.
‫We could also go to our content drawer, go click on C++ classes folder and hit add and hit add new
‫C++ class.
‫And then what we can do is we can go and scroll down to where you see it says scene component.
‫So we're going to make.
‫You seem component rather than an active component.
‫And we're going to go ahead and hit next.
‫Now we're going to call this the grabber because it's a component that's going to be eventually responsible
‫for figuring out what to grab and then grabbing hold of it so that when we move, the grabber takes
‫it withers.
‫So we're going to go ahead and create this class, which takes us over to Visual Studio code with a
‫grabber and a grab a dot CP and you can see that it's created a U grabber again with this U prefix for
‫components and it inherits from the you seen components.
‫That's how we know it is a is a scene component.
‫Again with that inheritance being the is a relationship.
‫If we went over to the mover to H, you could see that the inheritance is actually from you act a component.
‫So that is a a you act a component but otherwise it looks exactly the same.
‫It's got a big in play, it's got a tick component.
‫And that's because actually a scene component is an act, a component.
‫It just adds some more functionality on top.
‫So now that it's a scene component, we should be able to go over in to our editor, go to our BPE player,
‫and from here go to add and look for the grabber and the grabber.
‫Now you see, I had my first person camera selected, so automatically added the grabber as a child
‫component of that first person camera.
‫So I'd like to challenge you to print the grabber rotation.
‫The way we're going to do this is to get the component rotation this time, not the actor's rotation,
‫because the important thing is actually how this particular component is rotated because it's attached
‫to the camera.
‫We're going to convert it to a string using the two compact string function of the F rotator.
‫This time, because we're not using an F vector for rotation, it does actually have a two compact string
‫function.
‫However, then we're going to print that out using the EWI log.
‫Remember you put a star before a string for strange reasons and then we're going to compile it, test
‫it out and see does it change the rotation?
‫Does it move with the camera, pause the video and have a go.
‫Okay.
‫Welcome back.
‫So we're going to be printing this out in tech.
‫I didn't mention that, but hopefully you figured that out.
‫And what we're going to do is, first of all, create an F rotator, which is going to store my rotation
‫and then we're going to get component rotation, parentheses.
‫And then from this, we need to get an F string, which is going to be the rotation string, which we're
‫going to do by doing the mini rotation dot.
‫To compact string parentheses.
‫Now we're going to type you log and we're going to have the grabber rotation percent sx and then we're
‫going to remember the star before our rotation string like.
‫So now let's go ahead and compile this and it looks like that was successful, which is always nice
‫to see.
‫And then we're going to go ahead and hit play and have our output log docked in the layout so that I
‫can see it at all times.
‫You can see the rotation is indeed being printed out and as I move up you can see my pitch.
‫The P is changing.
‫As I turn from side to side, the yaw is changing, but at no point is it kind of tilting from side
‫to side, which would be the role.
‫So that's why in the compact representation, the role is always set to zero.
‫So you can think of it as role pitch and you're like in an airplane.
‫So it does look like this is updating correctly, as I would expect to with the camera and I'm very
‫happy with that result.
‫Great stuff.
‫So we've seen how we can create our own scene components, how we can attach them to stuff, and how
‫they have their own notion of rotation, location and scale.
‫Let's see you in the next lecture.