Welcome to your next quest.
For this quest, I'd like you to make a hit message.
Now, you can just use the same widget we're using for the damage number, but I want you to show an
animated floating message.
And we want to set the color and text based on blocked and critical hits for this message.
So now when we hit these enemies with our fireballs, we should not only see a damage number, but a
hit message as well, showing whether or not we got to create or a block.
So pause the video and conquer this quest now.
Okay.
So for this quest, I'm going to go ahead and just close out some tabs here, except for my damage text
and my damage text component.
Actually, you know what?
I don't think I need my damage text component either, so I'm going to close that.
All I need is my damage text widget.
Now I'm going to add text to this in addition to my number text.
I'm going to add another text.
So searching for text, I'm going to drag one just under my number text and I'm going to rename this
to text, underscore hit message and right away I'm going to check is variable and I'm going to set
horizontal and vertical alignment to center and scroll down and set justification to center.
I'm going to give it an outline size of one and let's change the font.
I'm going to change the font from Roboto to.
Nanum Brush script.
I kind of like this cartoony font.
You may not like it.
That's fine.
Choose whatever font you like, and I'm going to set the size of the font to really big like about 52.
So pretty big.
And I'd like to animate this.
So with my hit message text block selected, I'm going to click on animations and click on plus animation
to make a new one.
And I'm going to call this hit message Anim.
I'm going to select that and let's add a track.
I'd like to animate the Transform.
So I'm going to select text hit message, add a track for the Transform.
And for the transform at zero.
I think I'd like my translation for Y to be a little bit higher.
So I'm going to go into the negatives and not much higher.
I'm going to only go up to about -20.
Now at about 0.05 seconds.
In other words, really, really quickly, I'm going to bring that y translation up, which I should
specify.
I'm going to make the Y value more positive, which means the text block itself is going to go down.
I'm going to bring it to about 30.
So that's going to make it go down a bit.
But by about 0.15, I want it to go back to where it was -20.
So what that's going to do is make it go down and back up.
So it's going to kind of bounce a little bit.
Now, after that, I'd like it to sort of float up a little bit and a lot slower.
So I'm going to put a keyframe all the way out at one second and this will be a little higher, -35.
So let's see what this looks like.
There we go.
So it kind of bounces and then floats up a little bit.
But in addition to that, I like to animate this scale as well.
I'd like to start it off with a scale of zero so that it's really, really tiny.
You can't see it at all.
So at 0.05 seconds, I'm going to put the scale larger, 1.5 perhaps for both X and Y.
Now you do get the blurriness if we go above one.
So what we could do instead is let's see what 52 is times 1.5.
52 times 1.5 is 78.
So what I can do instead is make this font size 78, which is a lot larger.
And then in the animation, instead of scaling up to 1.5, we could just scale up to one.
And then we don't get that blurriness.
Now I'm going to scale it back down at about 0.15 and we'll bring it down to about 0.6 or so.
So scaling up to one down to about 0.6 and then we're floating up.
So let's see how that looks.
Yeah, that's looking pretty good.
Now we're floating up kind of slowly.
And while that's happening, I think I'd like to fade out our render opacity.
So I'm going to go from a render opacity of one all the way down to zero at the end here.
So for that, I'm going to need another track.
And I'm going to need to choose my render opacity.
And we can go from one at the beginning to zero at the end.
So I'm going to scroll all the way to the one second mark and enter a zero and let's see how that looks.
And that's looking pretty good.
So now that we have a hit message animation, what we need to do is play that animation so I can go
into the graph section and into the event graph, and here we can see that on event construct, we're
just playing the damage animation.
We can also play the animation for our hit message.
So I'm going to right click and call play animation.
And I need to get my hit message animation.
So hit message.
Annum is what it's called.
I'm going to get that, hook it in for the animation to play and hook up my play animation node.
So now when this widget is constructed, we should get that animation played.
So I can save all and test that out by coming over and causing damage.
And there's my message.
So now that we have the message showing, we need to set that message.
Now, this widget has a function called update damage text and update damage Text can also update our
hit message if we like.
And our hit message is going to be different depending on our two Boolean values, right?
So what we could do is we could create a function that could determine what that hit message should
be based on these two booleans, just like we're doing for color.
And then we can take our text hit message.
And we can call, set, text.
And pass in a text that we determine based on these two booleans.
So I'd like a function that can return a text for us.
So I'm going to click Add and add a new function.
And this one will be get hit message based on block and create kind of a long function name.
But it'll work.
So we need two Boolean inputs.
The first one will be is block, the second will be is crit.
And we need an output of type F text or just text here in blueprint.
And this one will be message.
I'm going to break that pin for now.
And what I'll do is just like what we did for our other get color based on block and crit.
I'm going to promote message to a local variable.
Call this out message, and then we'll set out message based on these values here.
So I think what I can actually do is take a look at get color based on block and crit and we can copy
these branches.
They're the same exact branches that we want to use.
So I'm going to copy that.
Go back to our new function and paste those branches in here.
And then all I need to do is promote is block and is crit to local variables, block and crit.
So I'm going to do that.
I'm going to take is block promote to local variable called block.
And take is credit.
I'm going to add a reroute node first and then promote a local variable called crit.
Like so.
And if I hit compile.
Oh, it looks like I already have the setters here.
I'm going to go ahead and remove those.
Hook these up.
And compiling.
I get errors, but all I need to do is right click and replace block with block.
Compile and that takes care of that.
And right click on crit, replace crit with crit and I'll need to do that for all of them.
Replace block with block.
Replace crit with crit.
So we'll do this real quick.
Not sure how much time this saved me versus creating more work for me, but it's okay.
It didn't take long to fix it.
Looks like I accidentally copied this make slate color.
Okay, so now we can set our crit message based on the situation.
First we have block no crit, so I'm going to take my out message and set out message.
And for block no crit, I'm just going to say block with an exclamation point.
And we'll go ahead and set that here.
And for crit no block I'm going to set it.
I'm going to duplicate this node and say critical hit.
Critical hit also with an exclamation point for block end credits.
I'm going to say blocked.
Critical hit.
And for no block, no crit.
I'm going to set this to an empty message.
That way we won't get anything and I'll hook up true and false to this.
And all of these can go into the return node.
So we'll get that one.
This one, this one.
And the last one.
I'm not going to bother cleaning it up.
I think it looks fine.
I'm going to compile and we'll go back to update damage text and we'll call our new function here.
So making some room, I'm going to call get message.
It's rather get hit message based on block and crit.
And we're going to at this point, I think promote blocked and crit to local variables.
So promote a local variable called block promote to a local variable.
Called crit.
We'll go ahead and use these now.
And we'll pass those in instead of having lots of red lines.
So doing a bit of organization, just something you kind of have to deal with in Blueprint, unfortunately.
And we'll pass these two in.
Here as well.
Now, once we have that message, I'm going to go ahead and promote that to a local variable.
So we're setting this text color, local variable.
I'd like to do that right here.
So we don't have too many nodes.
And wires crisscrossing.
And then right after getting the message, we'll promote message to a local variable called hit message.
And then after that, we have the hit message.
So doing it this way with a function is going to make it a lot easier.
You know what?
Damage should just be a local variable as well.
Let's go ahead and promote to a local variable and we'll call this hit damage.
Just because.
We're dragging this one green wire all the way across.
We could just have a local variable there and be done with it.
There.
That's much cleaner.
I like that better.
Couple reroute nodes and we're good.
Cool.
So now we have a hit message.
And now that we have a hit message, we can set the text for our message right here.
We can pass in hit message.
And now our message should be set.
We can test it out.
Let's do some damage.
Blocked critical hit block.
Blocked, critical hits blocked, critical hit, and the numerical values are reflecting what we see.
So that's looking good.
Excellent.
Now we're not setting its color, but that's pretty easy.
We can take that text.
Hit message.
And we can call set color and opacity.
And we already have the color.
It's going to be the same color as what we're using for our damage number.
It's called text color.
So changing the color now we should see.
Our message.
In the correct color.
And remember, if it's no block, no crit, we don't see a message.
But we do see a message for blocked critical hit for block and for critical hit.
Look at that.
We're getting some critical hits.
Now, this is actually adding quite a bit to the experience because as we're running around and killing
enemies, these blocks and critical hits, this visual feedback here is actually a really good indicator
that lets us know what's happening.
So it really can add a lot to the combat experience.
And now we.
Actually have a system in place that we can use to really do anything we want with the information that
we pass along in our effect context.
So this is a really nice feature to have and I think that it's really going to go a long way in our
game.
Now update Damage text could be refactored into several smaller functions if we like, but the way I
have it now, I'm actually pretty happy with how neat it looks.
So organize it if you like, but I'm fine with our function.
Everything's looking pretty nice.
Our git hit message based on block and crit and get color based on block and crit are similar.
So if you're so inclined, you could try to work on implementing the dry principle here in blueprint
if you like.
If you don't want repeat blueprint nodes like this, see if you can figure out how to make that happen.
If you do share that in the discord because other students would very likely really like to see that.
Now, one thing I'd like to do really quickly before wrapping up is I'm going to go into blueprints,
ability system gameplay abilities and go to hit React.
And I'd like to just change my instancing policy to instance per execution.
Why?
Because this is a lightweight gameplay effect and I'd like it to definitely play my hit React montage
every time a fireball hits so that way I can fire rapidly and we can always see that hit react.
Awesome.
We got our game play, mechanics working.
Things are looking great.
Congratulations.
And I'll see you in the next video.