Welcome back.
So now that we have attribute points and we're listening to the delegate for when they change, we need
to show those attribute points in our HUD in the attribute menu.
Now, every time we open the attribute menu, it's being constructed another time and it's broadcast
initial values is called.
So we need to broadcast our attribute points, getting them from the player state.
So I'm going to copy this line where we're getting our player state and paste it here in broadcast initial
values.
And I'm going to broadcast my attribute points change delegate.
That way my widgets can pick up on that, but I'm going to broadcast the amount of attribute points
we currently have, and I'm going to get that from our player state by calling get attribute points.
Now that we're broadcasting our initial values here, we should be able to see them.
If we bind to attribute points, change delegate.
So that's our next step.
Let's compile and open unreal.
Okay, so we have the editor open.
I'm going to open up my attribute menu.
And this widget here is where I'd like to show my attribute points.
Now, we have a problem, though.
This is a text value row.
Let's go to text value row and remind ourselves what that has.
It has text.
It has a value, it has a name slot and it's also doing some things here in the event graph, namely
listening for attribute info delegate.
Well, that's not something we need up here.
We don't need to listen to attribute info.
We need to listen to a different broadcast, a broadcast of our attribute points.
I'm going to make a separate attribute row specifically to receive attribute points.
So I'm going to take my text value row and duplicate it and call this one attribute points row.
And this one doesn't need a name slot.
I'm going to delete that.
So it's just going to have text and the text is just going to say attribute points.
And we have our value here.
This framed value.
Let's go into the graph and I don't need any of this stuff.
I'm going to keep event pre construct, but I'm not going to bind anything to attribute info delegate.
So I'm going to delete those.
I don't need an attribute tag.
I'm going to delete that and that's about it.
Now my attribute points row is going to need my event widget controller set.
Because as soon as I have my widget controller set, then I do want to assign an event to the attribute
points delegate on my player state, which I can get from my widget controller.
So as soon as widget controller is set I'm going to get my widget controller.
And cast it to attribute menu widget controller.
I'll cast to the blueprint version.
After casting this, I'm going to promote it to a variable.
Called BP attribute menu widget controller.
And with this I can get my delegate called.
Attribute points changed Delegate.
So I'm going to assign an event to that.
And all we need to do here is take our framed value widget.
So I'm going to bring that in.
And from the framed value widget, I need to set its value.
Now, just to remind myself, I'm going to open up framed value and see what its text block is called.
It's called text block value.
So I'm going to get that text block value.
And call set text on it.
And I'll take that new value.
That we get from our delegate broadcast.
We'll drag that straight in and get a to text from integer node.
And now we have something that will update based on attribute points.
And I just need to replace the widget in our attribute menu.
This text value row with my new attribute points row.
So it needs to go right here between two spacers.
First, I'm going to delete this one and then find attribute points row and drag that right there where
the old one was.
There it is.
Now compiling my attribute points row and my attribute menu.
Here's my attribute points.
Row and I can check is variable because I need to set its widget controller.
Now here in the attribute menu, the attribute menu sets its own widget controller by getting it with
our blueprint function library to get it from the HUD.
Then it calls its own broadcast initial values.
Now, when it calls broadcast initial values, it well broadcasts those initial values and any other
widgets who are bound to those delegates must bind to them before that broadcast happens.
So we can take our new attribute points row and set its widget controller.
But we have to do so before broadcasting initial values.
So we're going to call set widget controller on it.
And we're going to pass in the widget controller.
We can just use this one.
I'm going to make a root node and hook it in.
And now that we're setting the widget controller on attribute points row, when it's widget controller
is set, it will receive the delegate and update itself.
Let's see if we get that initial value of zero.
There it is.
We have zero attribute points.
Excellent.
So now that we're showing our attribute points, it's time to make our attribute points functional.
And for one, we should be getting attribute points awarded to us when we level up.
As it stands, we're not because.
Well, let's find out why.
First of all, if we go to our attribute set, I'm going to go to aura attribute set upkeep.
When our incoming exp changes and if we level up, we call these interface functions at the player level.
Add two attribute points and add to spell points.
Add to player level works, but add to attribute points and spell points doesn't.
Why?
Because when we implemented these in aura character, those functions were empty.
Here they are.
We have to dos.
Well, we could actually take care of those two dos right now because now our player state has functions
to add.
Let's go ahead and get that taken care of here in Add to attribute points, we're going to take Aura
player state and call add to attribute points.
Passing in an attribute points.
We'll do the same thing for add to spell points, even though we're not going to use that just yet.
We'll go ahead and take care of it now.
So we'll take our player state add to spell points, passing in in spell points.
So now that we've done that, actually we should be able to see our attribute points go up when we level
up.
So we can actually test that out.
So with a fresh compile and relaunch.
I can just take a look at my attribute points.
It's zero.
I can level up.
And now my attribute points is one.
Let's try leveling up with the attribute points menu open.
And there it goes to two.
So it's working.
So every time we level up, we get an attribute point.
My next goal is to be able to spend those points on our primary attributes with these plus buttons.
So we'll handle that in the videos to come.
Excellent job and I'll see you soon.