‫Hey.
‫Welcome back.
‫We're exposing variables to blueprints.
‫And now we'd like to talk about exposing our components.
‫This will allow us to set some of the properties, such as the meshes on our static mesh components,
‫as well as positioning our capsule and projectile spawn point.
‫Now we're back here in VS Code and we have all of our test variables.
‫And before we start going and exposing our private component variables, there's just a couple more
‫you property specific things we need to learn about.
‫For one, all of our test variables are in the public section and a couple of our variables here are
‫exposed to the event graph allowing read access and right access, and these are not allowed in the
‫private section.
‫For example, if I take our visible anywhere int and edit anywhere int and cut these and paste them
‫down here in the private section along with our components.
‫Here's what happens when we attempt to compile here.
‫We see in our terminal a couple of errors.
‫We see blueprint, read, write should not be used on private members and it says the same thing about
‫Blueprint Read only.
‫So what if we want read and write access in the event graph on private members?
‫Well, there's a way to get around this.
‫We can still have access to private variables in the event graph.
‫We have to add another input to the U.
‫Property macro and that input looks like this.
‫We say meta equals parentheses allow private access equals and in quotes true.
‫Now this looks pretty weird.
‫It's sort of a nightmare of syntax, but this is what it looks like.
‫You property macros allow for metadata and metadata is just a fancy word for data that gives information
‫about other data.
‫So we have this meta equals and if we use allow private access equals true, then we can expose these
‫variables to the event graph even though they're private.
‫Now, if you're a stickler and you don't think giving private access to a variable is a very good idea,
‫well, you don't have to do this.
‫This is just another tool in your toolbox that allows us to expose private variables to blueprint.
‫And on the C++ side, these are still private.
‫You still can't access these from other classes.
‫So you have that encapsulation on the C++ side.
‫This just gives you the ability to get these in blueprints and make changes to them.
‫And really in blueprints, it's kind of a different world.
‫Typically, you're not going to expose things to blueprints that someone could go in and change and
‫potentially break the game.
‫But it's useful to know how to do this.
‫So we're going to give this meta allow private access to both visible anywhere, int and edit anywhere.
‫And so let's compile this.
‫And now we see we have a successful compile even though we have blueprint rewrites and blueprint read
‫only on variables in a private section.
‫Now back here in BP Pond Tank in the event graph, I can right click and type edit anywhere and here
‫we see get edit anywhere int we still have access to it and if I search for visible, I see visible
‫anywhere int we can get and set it.
‫Now the last thing I'm going to show you that we can add to you properties is a category notice here
‫in the details panel.
‫These variables we've added are under this category based upon this is the name of the class and that's
‫where they go by default.
‫But notice that we also have other variables inherited by this class and they're each in their own categories.
‫Now we can create our own category for these exposed variables, and we do that by adding category equals.
‫And in quotes we can give this a category.
‫So I could call this super duper variables.
‫Now I'm going to have a comma here because I placed this here in the U.
‫Property macro as one of the inputs, and all of the inputs have to be separated by commas.
‫I'm going to copy this and add it to the U property here for edit anywhere int as well.
‫So now these should be in their own category called super duper variables.
‫Let's compile and back here in the editor, check this out.
‫We have super duper variables and our variables are here and I can right click in the event graph search
‫for super and check it out.
‫We have super duper variables and our variables are here.
‫So this is a nice way to organize our variables and make them a little bit easier to find.
‫So I've added a couple new things to our table here.
‫We can give private access, we can take private variables and still expose them to the event graph
‫with this meta specifiers.
‫And we can also give variables their own category to organize them in blueprints.
‫So now that you know plenty of ways to control the access to our variables in Blueprint, you're going
‫to fill out the you property for the components now decide.
‫Their access levels.
‫You're going to want visible anywhere for these because edit anywhere is not something you want to give
‫to your components.
‫This means you can actually edit that pointer variable and we don't want to change the pointer.
‫It should always point to the object.
‫We construct it in the constructor, but you can also decide whether or not to give them read, write
‫access in the event graph, give them a category.
‫This will allow us to keep our variables organized.
‫Now, if you're going to give them blueprint, read, write, or blueprint read only.
‫You'll need to allow private access with that meta specified to because these are private variables.
‫Now, once you've exposed the components to blueprints, then you can set some properties in the default
‫blueprint.
‫You can give the static mesh components their own static meshes.
‫So set that up in both the -- tank and in the turret blueprint and position the capsule.
‫So it's roughly encompassing the volume of the meshes and position the projectile spawn point, place
‫it at a point that would make sense for projectiles to spawn from.
‫So pause the video and expose our components to blueprint.
‫Okay.
‫So here we are in our private section, and we'd like to expose these components.
‫Now, first, I'm going to give my capsule component visible anywhere, and I'm going to just decide
‫to give this blueprint read only so I can access the capsule comp variable in the event graph, but
‫I cannot set it.
‫Now I'm going to give these the category and for our components here, I'm just going to give it the
‫category components now because I'm using blueprint read only, I'm going to use meta allow private
‫access equals true.
‫So I'm going to put that right there.
‫And for the rest of my components, I'm happy with these same you properties specifiers, so I'm going
‫to give them all the same specifiers.
‫Now I'm going to compile this and back here in the editor, I'm going to click on the viewport so I
‫can actually see what I'm doing here and I can select base mesh.
‫And for the static mesh property, since we're in the -- tank blueprint, I'm going to choose tank
‫base.
‫That's the base of the tank.
‫Now I can select the turret mesh and for its static mesh I'm going to select tank turret.
‫And now our tank blueprint actually looks like a tank.
‫Now before I set the projectile spawn point, I'd like to adjust the capsule component.
‫So it's roughly encompassing the volume of the mesh.
‫Now with the capsule component selected, we have these properties capsule half height and capsule radius.
‫I'm going to scale the radius and the capsule half height just so that this is looking like approximately
‫the correct shape.
‫And I'm going to need to position my tank so that it's down at the bottom because our capsule component
‫is the root component.
‫We have to move all other components relative to the root so I can select the base mesh and move it
‫down.
‫And to get it just right, I can angle my view like this, or I can come up here where it says perspective
‫and select, right?
‫And I'm now in orthographic mode.
‫This place is everything on a plane so I can move things and get them.
‫Just right now I'm going to turn off snapping so I can position this more precisely, and I think that's
‫looking pretty good.
‫Now I'm going to go back into perspective mode so I can see this and make sure everything looks good
‫and I'll select my capsule component and make sure the scale is just right.
‫Now, this may take a little bit of adjusting to get right, but with a few tweaks you can get it looking
‫pretty good.
‫So I'm satisfied with this.
‫Next, I'd like to position the projectile spawn point.
‫I'm going to turn snapping back on and move it up just in front of the barrel here.
‫So this is looking pretty good.
‫Now I'm going to go ahead and save this and now it's time to set BP pond turret.
‫So here in BP pond turret, I'm going to set the base mesh.
‫So let's select the tower base and I'm going to set turret mesh to tower turret.
‫There we go.
‫Now I'm going to scale up the capsule comp and move the base mesh down and just tweak this until I get
‫it just right.
‫And again, I can go into orthographic view and turn off snapping and get this positioned approximately
‫the way I'd like it and go back into perspective.
‫I think that looks pretty good.
‫Now, the last thing is the projectile spawn point.
‫I'm going to turn snapping back on and position it right here in front of the barrel and I'll set the
‫snapping increments to five just so I can position it right in the front there.
‫Now make sure that the projectile spawn point is not too close to the barrel.
‫We're going to be spawning projectiles from this point.
‫And something that's tripped up some students is that their spawn point is too close to the barrel and
‫there's a collision there which can result in complications when spawning projectiles.
‫Now this can be easily solved by making sure the spawn point is a good distance away from the barrel.
‫And we'll polish this up at the very end of this section of the course.
‫Okay, so the last thing I'm going to do is place a few of these in the world.
‫I've already got a BP pond tank here.
‫I'm going to set that down on the ground.
‫And let's drag in a couple instances of BP pond turret.
‫I'm going to place one here and rotate it so it's facing outward and then I'll go ahead and just place
‫one at each corner here.
‫So that they can guard this central structure.
‫And this is looking a little bit more like the finished product.
‫There we go.
‫And of course, if I wanted to, I could view this from the top and in top orthographic mode.
‫I can position these more precisely.
‫But of course, this is a little bit less important in a polished game.
‫You're going to want everything to look just right.
‫Okay, back to perspective mode.
‫This is looking pretty awesome.
‫So referring back to our section plan, we've created our tank and our goal is for it to move throughout
‫the world.
‫So in the lectures to come, we're going to start learning how to do that.
‫So in this lecture we have exposed our components to blueprints and we've set some properties in the
‫blueprints for the tank and for the turret.
‫Excellent progress.
‫I'll see you in the next video.