Welcome back.
Now in this video, we're concerned with making a new interface, one that any actor can implement if
we'd like to be able to highlight it when hovering over it.
So for that, let's go to our C plus plus classes, Aura Public, and we'll go into interaction where
we have our interfaces.
We'll make a new interface here.
So we'll scroll down to the bottom, make an unreal interface.
And this can be our highlight interface.
So we'll call it highlight interface.
Create the class.
And close the editor.
Now the highlight interface is just going to have a couple of functions on it.
So let's take a look at it.
Here's highlight interface I'm going to open the header file though I almost accidentally moved something
into another folder unintentionally but I canceled that.
Here's highlight interface dot h.
And let's get Combat Interface open as well so we can see what we've got in combat interface for highlighting
and UN highlighting.
Actually it's not in combat interface is it.
It's an enemy interface.
That's right.
Enemy interface is actually kind of simple.
It has highlight and unhighlight actor, but it also has set combat target and get combat target.
So quite simple.
Our highlight interface is going to be simple as well.
Now as soon as we move these two functions into highlight interface, we're going to break something
in the player controller.
As the player controller is checking for the enemy interface when performing its cursor trace.
So we are going to need to fix that.
So what we can do is we can move these two functions with control X.
Into highlight interface right here in the public section.
And now we have to do a couple things.
First of all, we need to go into the controller class.
I went ahead and close aura dot h and let's go into the private folder, into player, into Aura player
controller, where we're now going to see some red due to the interface that we're casting to in Cursor
Trace.
So what we're going to do is change what we're casting to here.
From I enemy interface to I highlight interface.
We can do that here I highlight.
Interface.
That's going to auto include that header file.
But this actor and last actor are not highlight interface pointers.
They're I enemy interface pointers.
So we're going to need to change that to here in our player controller dot h.
We're going to want to change last actor in this actor to I highlight interfaces.
Now we're going to have a forward declaration here for I highlight interface.
Like so.
And if we search for AI enemy interface, we'll see that we don't actually need that forward declared
here, so we can remove that.
Now back in the cpp file, our last actor and this actor are.
Now I highlight interfaces and we're calling highlight and Unhighlight on those actors.
But the thing is they'll always be null because our enemies don't implement the highlight interface
at all.
What they implement is the enemy interface.
So we have to implement the highlight interface in our enemies now.
So what we can do is we can go to the character folder.
I'd like to go to the public folder.
And open Ora enemy.
Where we have highlight and Unhighlight actor.
Now I don't want to remove the enemy interface.
Enemies need to implement that.
I just want to add an additional interface we're going to implement.
I highlight interface now, and that does require the header file for the highlight interface included.
And now these functions are overriding the highlight interface virtual functions.
So we can change this comment to say highlight interface instead.
Now with that, we should still get the same exact behavior.
We can hit debug and just test things out to make sure that everything works the same way.
Okay, so we're back.
I think I'm done with my post process highlight material now this enemy still starts off highlighted
as ten, and that's because I set its custom depth stencil value in its details panel.
If we want to get rid of that, we're going to need to change that back.
So what I can do is set this value to zero and uncheck Render Custom Depth pass.
That's going to fix that.
And now if I press play, it's not highlighted, but it's still highlights because it implements the
highlight interface.
Now.
Now this is great because now we don't have to just have enemies be highlighted.
We can have anything else implement the highlight interface.
As long as they implement highlight and unhighlight we should be able to highlight them.
The problem is though, if we hover over a highlight interface and we click, as long as we have abilities
which loading in without loading from disk.
Now I don't get those abilities, but if I did, I would cast that spell assigned to my left mouse button
when highlighting over a highlight interface.
That's because our code is all the same.
We get the same behavior in the player controller.
When we left click, we have ability input tag pressed and released which check whether or not we're
highlighting.
We have a boolean called targeting, which is set to true if this actor is valid, false if not, and
that actor is null or not based on casting to the highlight interface.
So if we want to be able to highlight something without this property of left clicking and casting a
spell targeting it, well, we're going to need to make a couple changes to the player controller and
have the ability of knowing that whatever we're highlighting is an enemy or not an enemy.
So we're going to focus on doing that next.
We'll have some changes to make to the player controller so that we can highlight a non enemy.
And if we click on it, we don't get the behavior of casting a spell targeting it.
So we'll do that next.
I'll see you soon.