Welcome back.
Now I'm going to show you an interesting.
We could call it a bug, but we'll say an interesting feature that I'd like to change in this video.
And that's if we're activating our electrocute ability and we're holding that input.
So we're staying in that shock loop.
We haven't released it yet.
We're still in the shock loop and holding that right mouse button down.
If I left click at the same time, you'll see that we're actually doing things right.
Our player controller knows that we're left clicking.
And in fact, if I say hold shift and left click will actually cast a spell which we're not supposed
to cast.
And if we click on, say, an enemy, well, that will happen too.
That's not supposed to happen either.
So we need a way to disable certain things from happening.
These are all happenings that are triggered inside of the player controller.
So what I'd like is an easy way to disable things in the player controller, such as input pressed and
released, callbacks being called, and maybe even the highlighting that's happening there.
I'd like a way to disable things easily, right?
If we're activating our electrocute ability, I'd like to disable stuff.
Now, the gameplay ability system makes this easy because if we go into our electrocute ability, notice
that we have these tags and we have the activation owned tags, which are tags that are applied to the
owner, which is the owning ability system component, while this ability is active.
So if this ability is active we can give a tag or 2 or 3 or however many we want to the ability system
component.
Now this is pretty useful because our player controller can check our ability system component to see
if it has any tags.
So I'd like to create some tags specifically for disabling certain things like input pressed, input
released, input held.
And then we can add any number of those tags to our ability system component while we're in this electrocute
ability while it's active.
So I'm going to go ahead and close out of the editor, and we're going to add a couple of native gameplay
tags to our project.
So I'll go to.
Or a gameplay tag stage and we'll just add a few new gameplay tags.
So I'm going to have a new gameplay tag, and these will be under the super tag player.
So they can be related to, say, the player, player controller, or player state things that the player
does.
So for example, we can have player dot block dot input.
Pressed.
We can have player block input held.
We can even have a player block input released.
And I'd also like a player block highlight.
Or rather, we could even block cursor trace altogether.
And that's that cursor trace that we're doing in the player controller.
So we can have any number of these that we can grant to the ability system component.
And we can always check these tags on the ability system component before doing any of these things
in the player controller.
So I'm going to make these tags.
Let's go into the cpp file.
We'll go all the way down to the bottom and we'll add a multi-line comment first.
We'll say player block tags.
And in fact, we can just make these player tags because they don't have to all be block tags necessarily.
So let's make these new tags.
We're going to start with player block.
And we'll just go from top to bottom.
So we'll start with Cursor trace.
And the name will be player dot block dot cursor trace.
And for the string we'll say block tracing under the cursor.
We can copy this and paste it.
And we'll have the next one.
And this will be player block input held.
And we'll change it to player dot block dot input held.
And we'll say block input held callback for input.
We'll go ahead and make the next one.
Player block input pressed and we'll change this to input pressed and we'll say block input pressed.
Callback for input.
We'll do the next one.
And that's going to be released.
So player dot block.
Dot input released.
Block input released.
Callback for input.
So now that we have these native tags, what we can do is give these to the ability system component.
When activating an ability if we want to.
And as long as we're checking these and preventing things from happening, we can block these phenomena.
For example the cursor trace.
Let's go to our player controller where we're doing that.
So in player or a player controller notice that we have a cursor trace function.
Right here.
Let's go to that.
And here in Cursor Trace we're doing all this stuff, but we can block it all if the ability system
component has that blocked tag.
So we can say if and we have a git ask here.
So only if that's valid at the time then we can check the ask.
So I'm going to have an and in the check and say and git ask.
And if we search for has.
Then we have things like has any matching gameplay tags.
Has all matching gameplay tags, has matching gameplay tag, and if we go to the function.
We can see here that has matching gameplay tag comes from the AI gameplay tag asset interface, and
this checks the gameplay tag container that the ability system component has.
And this can check for a single tag.
So really all we need to do is pass a tag in here we can use F or a gameplay tags get.
And we can check for that player.
Block cursor trace tag.
Now, if the ability system component has player block cursor trace, then it can simply return from
this function and never even trace anything.
But if we're already highlighting something, well, we could just clear out unhighlight anything that's
highlighted.
So I'm going to take these two lines here.
And we can call Unhighlight actor on both of them.
And after calling Unhighlight actor we can set them both to null pointer.
So last actor is equal.
We'll set it equal to null pointer.
And this actor will set that equal to null pointer.
And we'll return.
And of course these two checks will fail on the next time they're checked because we just null them
out.
So cursor trace is going to be checking for this blocked tag.
And we won't bother tracing and highlighting things.
And we'll actually unhighlight everything if we have that block cursor trace tag.
So that's how we can block cursor trace.
Now that's not the only tag we made.
We also have block input held released and pressed.
So if we go to those functions we have ability input tag pressed.
So we can check for tags here.
So what I'm going to do is just copy this if statement.
And right here in ability input tag pressed we can make a check only we're not going to check for player
block cursor trace.
Instead we're going to check for player block input pressed.
And if we're blocking pressed input we can return.
So we're not going to send ability input processed data to the ability system component.
We're going to return instead.
It'll be like we never actually clicked the mouse button.
Now we can block released events as well by simply doing the same thing, but changing the block tag
to input released.
And we can do this for input held as well.
We can have ability input tag held.
Place the check for the block for input held.
And return in that case.
And of course, we also have another callback bound to input.
If we take a look at our move function, we also even have the shift pressed.
If we wanted to block that.
So the move function is going to move us right.
That's going to be for wasD movement.
We can also check block input pressed and return in this case.
And if you want you can do it for shift pressed and release.
But I don't think that's going to matter now because we're blocking everything else.
Now let's hit debug and launch the editor.
So back here in the editor in electrocute.
Now we can add some tags for activation own tags.
Now the cool thing about this is any tags we add to this will be granted to the ask upon ability activation
and removed from the ask upon the ending of the ability or cancellation.
So we can add any number of these player blocked tags.
Now when in the electrocute ability I want to block the cursor trace.
I also want to block the input pressed and held events, but not released because we're waiting for
input release.
We'll never get that if we're blocking that, because we're blocking this at the player controller level.
So we can just have these three block tags cursor trace input held and input pressed.
And what we can do is press play.
We can hold this down.
And if we left click.
All we're getting, actually is our Niagara system.
We're actually not blocking that.
We're going to have to take care of that.
But if we hold shift and click, we don't get our left mouse button ability and we can't actually highlight
any of our actors.
Now I'm going to highlight this actor.
I'm going to right click just to make sure that we see that highlighting has stopped.
So right click I can left click and I don't get anything other than our Niagara system.
So we'll need to fix that.
But if we're already highlighting and we right click it's going to stop highlighting that enemy.
So that's something to be aware of.
Now, if you don't want to block that, you can just remove that block tag from activation own tags.
So we can take cursor trace.
We can cut that out and then we'll still trace.
The thing I don't like about that is if we're hiding the mouse cursor and I move the mouse up to that
enemy, it'll highlight.
So that's why I want to actually include that block tag cursor trace in activation own tags.
Okay, so this is looking and working great.
I do want to suppress that Niagara click effect.
So what I'm going to do is check if player block input pressed is a tag we have before playing that
Niagara system.
So I'm going to search for Niagara.
And we're going to place a check here.
And I'll just say if get AC and not AC has matching gameplay tag, if we don't have this tag then we
can spawn system at location.
So I'll put that in here instead of returning.
And that way we just prevent that Niagara system if we're blocking input pressed and that's fine.
Now you could be more specific and go add a gameplay tag to specifically block spawning this system
if you wanted to do that as well.
But I'm okay with just using this tag.
So last thing to check.
Let's make sure that we're not spawning that system while electrocute is active.
All right, I'm going to get this back open.
I'm going to use my electrocute ability.
I'm going to left click and I don't see anything.
So it's like we're never actually left clicking at all.
And in fact, we can WASC and we don't get any movement there.
We're suppressing that as long as we're in our ability, so we can be left clicking and holding it down.
And right click will interrupt that with the shock.
And if I release the right mouse button now we're running again.
So it's actually a very nice smooth system.
And that is going to handle that little bug.
And actually we can add these to any ability as long as our ability system component has any of these
tags it will block the corresponding action that's related to that gameplay tag.
Pretty powerful.
All right.
Excellent job.
I'll see you soon.