In this video we're going to implement a simple fix so that when we click on an enemy the player actually
looks at the enemy looks them in the eye when these smacking them in the face rather than looking off
to wherever he's currently facing at the moment.
I want to start with a quick conversation about how do you know when to move on to the next feature.
So how do you know when to move on.
Well in early development I really want to make it clear.
Don't get stuck on one feature.
We've been working on our basic combat for a while now.
I think we're getting very close.
But how do we know when to move on well move on when you can pass this test.
Ask yourself the question Is there anything about this feature which is distracting or broken.
So when we look at our game here we can run around and say well yeah movement's not perfect but it's
not too bad it's not distracting it's not broken something I feel is broken when you click you're not
even looking at the guy that feels like this moment just to you that it's a bit broken to me and very
distracting to the player so you can have a player play your game be like What is he doing that you
don't want that you want to make sure that you eliminate those things.
Once we've eliminated those we have to get out of Dodge and move on to the next feature or else we'll
be spent in ten years making our game so what do I see are the last bits of twiddling for our basic
combat before we move on to say enemy II or the next feature.
Well I think we need to change our player just a little bit so he's slightly more handsome.
I give him a slightly different color because at the moment when you run around he looks the same as
the enemies and if someone was to play this right now I'd be like What.
Who would try my I think we need to make the player look at the enemies which is what I was just showing
him won't be doing that in this video.
And then the next video I'm going to make sure that the dead don't interfere with the thumping because
we've got an issue at the moment.
If I was to grab my enemy who's alive and move this enemy over.
So he's come running up hey you don't kill my buddy who comes running up and then I go to click on him
I can't click on him because he's dead buddy is blocking my recast so I can sort of move around and
sort of sometimes click em but a bit buggy and a bit messy that's going gonna be distracting and it's
also a little bit broken.
So that's my logic for what we're doing in the next couple of videos then we'll move on to the next
section of the course.
And how we going to resolve this current challenge.
Well I am going to show you transformed not look at you may have used it before.
Pretty straightforward if we read here rotates the transform of the game object so that the forward
vector points at the target's current position.
In other words it will rotate our player.
Beep beep beep beep beep.
So it will be its forward vector is pointing towards the target.
That's exactly what we want.
So I look at is really handy really handy tool to use.
And so this is a bit of a one line fix but I'm going to give that to you again as a challenge to look
me in the eyes and say that you'd transform not look at to turn the play out when clicking on an enemy
and what you need to figure out in this is two main things.
First of all where to add that where to call that method.
And second what to pass into it.
So we have to pass something into it.
We have to say look at this particular thing.
So there's your challenge.
It's only one line you need to add but a little bit of logic little bit of figuring out.
So take that on give you your best shot and I'll see you back here when you done okay.
Song and jump over into fighter dot c s and as I said it's just one line.
Let's start off by figuring out where should that one line be.
Well if we look at our update where first of all making sure we can attack.
Good.
Getting into range.
We're not in range getting range call.
And then when we are in range stopped moving got it.
And then do the attack behavior what's part of our attack behavior.
Look at the thing.
So within attack behavior I think the very first thing we should do when we're calling attack behavior
is to look at our enemy.
So transform dot look at now what are we going to pass him where we need a passing something's transformed.
Because it transforms its position in the world.
What's this something we're going to pass him was just going to be Target Target dot transform semicolon
that means we should be looking at it and I just want to remind you again this might be something you
do or don't do.
But if he gets stuck and you want a little bit of intel you watching Sam and I know what on earth are
these guys doing.
And you've just typed out exactly what we've typed.
Put your mouse over each aspect and see what it says.
Just to remind yourself what's going on.
So this is the transform attach of the game object.
Oh it's the game object that fighter is attached to go look at.
It's going to rotate the forward vector towards the position.
Right.
This is the target.
It's of type health.
Oh yes of course.
And then this is the transform so just right.
I know you know this.
I know you've been doing this but just a reminder if you get stuck sometimes tons of information when
you just do a little simple mouse over let's say back over in unity make sure this fix works hop in
the middle of a couple of guys here and click point turns doing great.
And down here turns turns gray a little bit of a little bit of glitchy ness every now and again.
We're gonna get that as I was saying before like that just then there was a little bit glitch before
he started attacking.
That's something that is a tiny bit distracting but I don't think it's broken at the moment so we're
not gonna worry about digging into that just yet.
Those little tiny glitches we want to keep pushing through keep getting features into our game and the
other thing I do in this video is just quickly change the color of my player.
I'm going to find the play a prefab which is under game characters and there is my play a prefab double
click on that that will open up the prefab.
Very cool.
Now if we go into the Sinti pack the Sinti polygon student pack we can see under materials we've got
a bunch of characters textures.
Now I've gone and made a couple of tweaks to these so that we can change up the colors.
You can see we've got a textured blue sari black just drop that over it changes it blue orange which
we've been using and red.
So if one of those takes you fancy then you might want to change it.
I'm going to change my character to blue because it also changes the beard to white.
I want my character to be an old guy so I'm going to click up in the top left because I'm doing that
straight onto the prefab which is how I like to do it.
It's a personal style I can just click out of the prefab and I know the change has been made to the
player game object that I've got in my scene.
Any of my player game objects because they linked to the prefab will have been updated.
Okay save that.
It's looking pretty good don't really need to test that the color works.
But now I think that my player stands out from the enemies and just makes it a little less distracting
for anyone that we might give our game to to say hey what do you think about our game.
Cool.
So in the next video we're going to take on the broken thing that I mentioned before about not being
out a click when there's a dead enemy in the way so I'll see you in that next video very shortly.