Welcome back.
Now we're just about ready to create blueprints based on aura, character and aura enemy.
And we know that we can add things to aura character base, and these will both inherit those things.
Now, I'd like all my characters to have a weapon, so I'm going to add a skeletal mesh component to
the Aura character base, and I'd like to attach that to a socket on the skeleton, which means we'll
need to make sure that our skeletal meshes have the socket that we specify.
So in our protected section in Aura character base, I'm going to make a weapon, which is a skeletal
mesh component pointer, and I'm going to use the T object pointer wrapper rather than a raw use skeletal
mesh component pointer.
Now, T object pointer is relatively new in unreal engine and a packaged build.
It behaves the same as a raw pointer, but in editor it has some additional features, such as access
tracking and optional lazy load behavior.
Access tracking just means we can track how often a pointer is accessed or dereferenced.
And lazy loading means that an asset can not be loaded until it's actually needed or used in the program.
So the standard is moving more towards using object pointers for member variables.
So we'll be following that standard in this project.
And object pointer in this case will wrap a used skeletal mesh component.
There's no need for the asterisk.
We don't need to add that star, but we know that this is a pointer and we'll call this weapon.
And I'm going to make this a uproperty as all of our member pointers should be, and we'll make this
edit anywhere and I'll place it in the category of combat.
So now we can actually create our skeletal mesh component in or a character base in the constructor.
So we'll say weapon equals and we'll use create default subobject here specifying the use skeletal mesh
component and in quotes we'll have simply weapon.
Now, if you're asking why I haven't used the text macro here, that's because create default Subobject
takes an F name and you don't need the text macro for F names.
You need them for f strings.
F string will take a string literal like this and perform an implicit conversion to a wide character
string as that's what the f string type stores.
But the F name can take a regular string literal just like this.
Now I'd like to attach the weapon to a socket on the mesh, so I'm going to say weapon setup attachment.
We'll attach it to the mesh so we'll access that through get mesh that's inherited from the A character
class, of course.
And we'll attach it to a socket.
So I'm going to use an F name here and we're going to add a socket to the skeleton.
We'll call this weapon hand socket.
So we'll place a socket on one of the hands and our weapon will be attached to that.
And the weapon should not have any collision.
So I'm going to take the weapon and call.
Set collision enabled using E!
Collision enabled.
No collision.
So that should take care of collision.
So now if we go and create some blueprints based on a character and or an enemy, they will have the
weapon skeletal mesh component and we can set the skeletal mesh in the blueprint.
Now, I'm not debugging any code, so I'm just going to hit run to compile and launch the editor.
And with the editor open, I can now start making some blueprints.
Now, I don't want things to be messy.
I want a nice clean folder structure.
So I'm going to have a new folder in content designated for all my blueprints.
And I'll call it blueprints.
And inside of blueprints I'll make a new folder called Character.
And here in character, I'll have the Aura character as well as all my enemy characters.
So here in character, I'll make an aura folder, and in Aura I'll make the aura blueprint.
So I'm going to right click and make a new blueprint class and search for Aura character.
I don't want Aura character base.
I want my Aura character.
So I'll select that and call this BP underscore aura character and we can go ahead and open it and set
the mesh for the mesh variable as well as our weapon.
So first the mesh.
I'll take my skeletal mesh asset and right here we have Sxm aura.
That's the aura skeletal mesh.
I can move it down.
I'd like snapping enabled for translation and rotation.
I'll move it about 90 units down and exactly 90 units rotated.
So it's forward and we can set our weapon.
Before we do that, I'm going to add that socket that we called weapon hand socket.
I'm going to actually copy that name and I'll take my aura.
Let's browse to that and open it up and choose where we want the hand socket.
Now the question is, do we want this on the left or right hands?
And the animations that we have for aura, use the left hand.
We can see that by going into the animations folder here in the same folder that Sxm aura exists in.
And we can just take a look at, say, the idle animation.
We can see that aura holds the weapon in the left hand.
So back in Sxm aura, I'm going to add a socket to handle.
That's the handle bone.
We're going to add a socket.
I'm going to click it.
I'm going to click it again and paste in weapon hand socket.
That way it has the correct name and we can position that socket by right clicking and adding a preview
asset, searching for the staff.
I'm going to get that skeletal mesh asset Sxm staff.
The staff is the static mesh.
I want the skeletal mesh and I'm going to go ahead and rotate it by about 90 degrees.
And I want to preview this with an animation so I know that I'm positioning things correctly.
So up here under animation, I can set preview controller to use specific animation.
And for the animation I can choose any one of these.
I'll choose Firebolt here and we have Aura casting a spell.
I'm going to pause it somewhere in the middle and move this socket so that it looks correct.
I'll move it forward a bit and just make sure that it looks good.
I think that looks pretty nice.
And I can switch to, say, the idle animation if I want to make sure it looks good there and perform
any last minute tweaks.
So I might actually angle it forward a bit.
Let's take snapping and disable that for rotation.
And just make sure it looks good.
Okay, great.
So we have the socket.
We can go back to our character, select the weapon, and we can set that skeletal mesh.
I'm going to search for staff and we have Sqms staff and we see that it's attached to the correct socket.
And if you want to see that staff, just browse to it and inspect it.
It's got some nice textures on it, really pretty staff.
So that's going to be aughra's weapon.
Okay, great.
So we have the Aura character blueprint and that looks great.
We can also make a blueprint for the enemy class.
We'll go ahead and make one of those before we wrap it up.
And that's actually going to be your quest.
So for this quest, you're going to make a blueprint for the Goblin Enemy.
Call it Goblin Spear now set the mesh and search for the goblin skeletal mesh in our assets folder and
check out the skeleton on that goblin.
Make sure you take care of the socket and then you can find the spear asset and set that for the weapon
on the goblin blueprint.
Go ahead and pause the video here and take care of making the Goblin Spear blueprint.
Okay, so let's conquer this quest.
I'm going to go into my character's folder and next to Aura, I'm going to make a new folder and I'll
call this goblin underscore spear.
And in Goblin Spear, I'll right click and make a new blueprint based on aura Enemy.
So I'll choose that class and call this beep, underscore goblin, underscore spear, and I'm ready
to open it up and set the mesh.
So I'll select the mesh and search for Goblin.
In fact, it's right here.
I can go ahead and select it.
I can move it down, I can rotate it by 90 degrees.
I don't have snapping on it looks like.
So I'm going to undo that, enable snapping and rotate by 90 there.
Now this is a little guy.
We can make that capsule a bit smaller.
So we'll go ahead and just bring it in a bit.
Just a cute little goblin enemy.
It's going to be really sad to kill these guys, but that's the price you have to pay to be a hero,
right?
So I have my goblin.
It needs a weapon as well.
So let's take care of the socket situation.
I'm going to browse to goblin, open it up and look at that.
We do have a socket on the left hand bone.
Now I'd like to see what it looks like with a spear so I could right click, add a preview asset and
search for spear and choose the spear.
That's the skeletal mesh component.
Looks like it's in the correct location and we can set the preview controller to use specific animation
and see if we have any spear attack animations.
Looks like we have attack spear and it looks pretty good.
I don't think we need to really do any adjustments on that.
Thanks to the creator of these assets positioning that socket correctly for us.
All right.
Now we do need to make sure that that socket name is correct.
Hopefully this didn't trip you up.
It needs to be weapon hand socket.
So we are going to need to rename this socket.
I'm going to paste in weapon hand socket and save that.
And now in Goblin Spear, I can select weapon.
I can search for spear and set that weapon to the spear and it looks good.
So now we have a weapon based on aura enemy called Goblin Spear.
And if you'd like to see what they look like next to each other, if you're curious, you could drag.
In an instance of these blueprints.
I can browse to Aura.
Drag aura in there, and I can browse to the goblin.
And drag in the goblin.
And as you can see, the goblin is a good deal shorter than aura.
So that gives you an idea of what they look like.
I'll go ahead and delete those, however, I don't need them in the world just yet.
And now we have some characters to work with.
Excellent.
I'll go ahead and save all before I close out of the editor.
And we're now ready to create some animation blueprints for our characters and we'll do those next.
I'll see you soon.