♪♪♪
(Wes Bunn) Hello everyone and welcome. In this video, we are going to create a custom
projectile entirely in Blueprints. What we are looking at here is the Blueprint Third
Person project. I am going to hop in and Play and show you what it is we are going to create.
We are going to create a flaming chair that you can shoot at people because flaming chairs
are awesome. Aren't they? So there we go. That is what we are going to create together
here. Let me press Esc and minimize that. Here we are with a brand new, fresh Blueprint Third
Person Template map. Now you can use any project you want, but if you want to follow along
and have a flaming chair that you can shoot, I suggest that you use the Blueprint Third
Person project. Make sure that starter content is enabled. With that, let's get started.
In the Content Browser, click the Add New button. Go up to Blueprint Class; go ahead and select that.
In the Pick Parent Class, we are going to select an Actor. We are going
to make this an Actor. Let's call this Blueprint "FlamingChair". Then, go ahead and Double-click
on it to open it up. That will open the Blueprint Editor and it will open to the Viewport tab
allowing us to look at all the Components that we can add. So let's start adding some Components.
In the upper left under the Components window, click the Add Component button. The first
thing that we are going to add is a Collision. So if I type in "Collision", we get a couple
options here. Traditionally, you would use a Sphere Collision for your rounded bullets,
or a Capsule Collision for your machine gun bullets or whatever. For us, we are going
to use a Box Collision because we wanted something custom. So, let's go ahead and use a Box Collision.
I am going to call this "Collision". With that, we are going to hop over to the Details
panel here. For the Collision Presets, we are going to make a change here. It is currently
set to OverlapAllDynamic. We are going to click this drop down and make it BlockAllDynamic
because it is our collision. We are going to add another Component. We are going to
add a Static Mesh. So let's go ahead and search for and add a "Static Mesh". We are going to call
this "Chair". For our Chair here, let's go to the Details panel. Under Static Mesh click
this drop down and search for "Chair". So there is our SM_Chair. It is a little bit
bigger than our Collision, so I am just going to drag it down a little bit. Then I am going
to hop back up to our Collision here, and I am going to scale up the Z-Axis on our Collision
here just by dragging this over. Maybe the Y-Axis too; something like this. We could probably
do the X-Axis a little bit more actually. There we go; something like that so it will encapsulate our chair.
I am going to hop back to the chair and move it down so that it fits inside our Box Collision.
This looks good enough to me. Good enough. The next thing we are going to add is click
the Add Component and search for a "Particle System". So go ahead and select that. This
is going to be called "Fire". I am going to hop over to the Details panel under Particles
and Template, we are going to click this drop down here and select P_Fire. Look at that;
our chair is already on fire. One thing that we need to do is go back to the Components
panel over here. Grab our P_Fire, Left-click on it, and drag and drop it on our chair.
So wherever our chair moves, our fire moves with it, which is what we want. Let's add
another Component here. Let's click the Add Component button. We need to add a Projectile
Movement. Projectile Movement Component. The Projectile Movement Component is very
handy because it includes a lot of stuff that will handle all of the functionality of a
projectile such as speed, Bounciness, and all kinds of other things. We are not going to change
or go through all of these together, but we do need this Component. We are going
to make a couple changes on it. So the first inside the Details panel, we are going to
head down to the Velocity section here. Under the X, we are going to change this to about
200. Move along the X-Axis in 200 units. So that is if you go to the side view here, you
can see our X-Axis; we are going to move it in this direction 200 units initially.
Our Initial Speed, let's go ahead and bump this up. Set this to 2000 so that it is going
2000 units per second. For fun, let's go to Projectile Bounces and make sure that it bounces.
Should Bounce; yes, this chair should bounce. One other thing, actually. Let's go back to
our chair really quickly. Let's select our Chair and inside the Viewport here, let's
hit E. We are going to rotate our chair just a little bit so it is launched like that.
Let's move it up just a little bit. I think that is good. Good enough. So it is going
to launch like that when we launch it. The other thing we are going to do is we are going
to go back up to the Components and add one more Component. We are going to add a Rotating
Movement Component. Rotating Movement Component; this is a really handy thing because now with
this, we can have this chair continually rotate in a direction. So with that, let's select
our Rotating Movement Component. We want to rotate it... Let's rotate it along... Let's
zero out the Yaw. Zero that out. For the Pitch, we are going to make this 45°. Now if we
hit Simulate, woah! Our chair goes flying off, but you can kid of see it rotating. We
may want to change our Projectile Movement Initial Speed a little bit. Our Initial Speed is 2000;
let's actually bump that down. That was a little too fast for a chair. So let's go ahead
and bump that down to say 1200. Let's pull back a little bit and Simulate again. Boom!
There we go. Look at it; it is rotating. That is cool. I'm happy with that. With that, let's
see; I think that is all we need to do for our FlamingChair. Let's Compile and Save.
Well, you know what? There is one other thing we can do. Let's go to our Projectile Movement
Component here. If we scroll all the way down to the bottom in the Details panel, we have
a couple options. We have On Projectile Bounce and On Projectile Stop. So I am just going
to demonstrate this really quickly. Let's go back to our level here and just drag in
a FlamingChair. So if I just drag and drop in a FlamingChair here and I move this up,
(I am going to go to Simulate actually and simulate this) it will launch our FlamingChair.
However when it stops, look what happens. It keeps rotating in place, which isn't cool.
So I am going to stop, go back to our FlamingChair Blueprint here, and select our Projectile Movement Component.
When the projectile stops moving, we are going to stop the rotation. So I am going to click
this add button here (+ On Projectile Stop). It is going to give me a new node on our graph,
which is where we provide all the scripted functionality for our Blueprint. So, what
we want to do is grab our Rotating Movement Component here. I am going to hold Ctrl and
drag that in. Then what we are going to do is Left-click, drag off the Rotating Movement
Component, and we are going to Set Rotation Rate. The Rotation Rate is what we want to set.
So with that, we are just going to Left-click, drag, and connect it like so. All we are going
to do is leave this as 0, 0, 0 because we want to stop rotating. Just for fun, let's
actually hold Ctrl and drag in our Collision as well. Left-click and drag off of this.
Let's say, "Set Simulate Physics". There we go. Let's connect the executable from the
Set to the executable to Set Simulate Physics. Our new value is going to be true. So once
we stop moving, we are going to stop our rotation but then we are going to set our chair to
be a physics object. So let's Compile and Save and hop over to the editor over here.
Let's see if this is working. Find our FlamingChair. Let's Simulate. Boom! Boom, boom, boom, boom,
boom! Yes, it looks like it is a physics object. Our Collision is kind of bumping up against
the wall here. But I think that is good. Let's go ahead and Stop. The last bit of business
we need to do is allow our Character to actually launch this chair. So what we are going to
do is let's find our Character Blueprint that is being used for this. So there are a couple
different ways we could do this. For our instance, we are using ThirdPersonBP template so it
is going to be inside the Blueprints folder. Right here is our ThirdPersonCharacter. Another
way you can get to this is if you go to Settings > World Settings, you can see that we are
using the ThirdPersonGameMode. If I browse to this, which is actually right here in this
same folder. If I Double-click and open this, you can see the Default Pawn Class that is
being used. Your Character may be different if you are using a different project, but
for us, we are using the ThirdPersonCharacter. But this will allow you to browse to whatever
Character is being used as the Default Pawn Class. Just a note just to help you find it
if you can't find it. So, let's go ahead and open up the ThirdPersonCharacter Blueprint.
I am going to scroll down a little bit by holding the Right Mouse Button (RMB) and dragging
in our graph here. This script pertains to our Character Movement. We are not going to
worry about any of this because our Character can run around, jump, and everything right
now. But it can't shoot, so we are going to add that functionality. We are going to Right-click
and search for "Left Mouse Button" because this is typically the button you use to fire
stuff in games. So Left Mouse Button and we have a Pressed and Released. We are only going
to worry about the Pressed. We are going to Right-click again and search for "Spawn Actor
from Class". So Spawn Actor from Class is the one that we want. We are going to connect
the Pressed to the In here, like so. The class that we are going to spawn is our FlamingChair.
So when I start typing in "flaming", I get the FlamingChair option. It is asking for
a Spawn Transform to spawn at the location in World Space for where to spawn it. To get
that, we are going to Right-click and search for "Get Actor Location". So Get Actor Location,
which is our Player Character. We are also going to Get Control Rotation. So if we search
for "Get Control Rotation". So Get Control Rotation is the Rotation of our mouse as we
move it in game. So we want to get that Rotation and see which way we are aiming. So now that
we have both of those, we can Right-click and say, "Make Transform" because this is
asking for a transform. You can see that we have the Location and Rotation. We could plug
both of these in right now and connect this to the Spawn Transform. However, what would happen
is we would spawn the FlamingChair right inside of our Player Character and we don't want that.
So what we are going to do is actually, we can connect this right now. What we are going
to do is from the Control Rotation, we are going to Get Forward Vector of that. So get
which way is forward. Yeah, it is right there. Get Forward Vector. We are going to multiply
this by a float. Let's hit the multiplication key there (*) and we are going to
Vector * Float. Let's just say 800. Then what we are going to do is let's drag off the Return Value of our Get
Actor Location here and add a plus sign (+). Vector + Vector, like so. Connect this
Multiply output pin to the Addition input. Connect the addition's out put to this Make
Transform node's Location. Connect our ControlRotation Return Value to the Make Transform Rotation.
There we go. Let's Compile and Save. Let's Play in the editor and see if that works.
Let's make sure we are not on Simulate first. So let's Play. So there we go. We are launching
our chair from our Character. It is a physics object now, once it stops rotating.
So, this was a little bit longer of a video but it is a little bit cooler, I think, than
a traditional projectile. I hope you guys enjoyed it and learned something. Thanks for watching.
♪♪♪