Welcome everyone to this new video, so we didn't hear we have the project that we last left off in
the last video.
And as you can see, if I press play, I can move around, I can look, I can explore around a bit,
but there isn't a lot to do.
Today we are going to be discussing a little bit how to create more colors within our level so that
there is a little bit more of a diversification in colors.
And afterwards, I'll show you how to change those colors and modify them using blueprints.
So let's start off with colors.
So usually whenever we have anything with, you know, real.
So as you can see anything that we can see.
So for example, these little chess like structure of the texture of this object, which is called default
material.
These cubes, which are white so in themselves, have that specific color.
And even our little player, which has a similar structure as the one that the floor has because we
are using the same, let's call it color for now.
So how do you change these things within a real this coloration?
These textures that we see are usually changed through something that it's called materials.
As you can see here on the top, in the bottom right, whenever we're pressed on any object, any object
that has any sort of texture, something that we can see of it usually has a texture, a texture and
a material.
And we can modify it as it kind of is a blueprint in itself.
So I'll show you how to do this.
Let's create another folder.
Let's call this folder materials within here.
We right click and we go into the material.
The basic facet and we'll call this m for the stands for material underscore.
Let's call it red for now, which arguably represent the color red.
If we double click on it, it will open up a new tab.
This tab has a very similar architecture to the one that Blueprint class has.
We have here on the right and a lot of different variables and methods that we can use on the left.
We have the detail panel which shows everything we click on.
And here we have the parameter vote as well, which is used that you can guess to change parameters,
and here we have kind of like similar to the The Scene tab, something that shows us the final color
of our current material.
So for now, I'll stick to very simple things.
I won't be going over all of this because these are actually more of an artistic focus of lecture rather
than a technical one.
For now, if we want to change the color or we need to know is that the base color is the one we are
looking for.
If you're interested in knowing about more, you can simply play around with things so you can actually
look around for some courses based on specifically material, because materials kind of like blueprints
have their own specific things that needs to be learned.
And these things are not going to be shown here in this tutorial.
We are just going to be using blueprints to change materials.
So.
Base color, what I have done here, apologies is right click promote promoter parameter.
In this way, I create a new parameter which is going to be called base color.
And here, by clicking on it and going into the details panel, I can actually see the different variables
I can change.
For now, we are going to change the parameter name as red because it's just simpler and we are going
to be changing the default value here to red.
And we amp up this little tab over here to make sure that the these values are not going to be zero,
therefore black.
This is kind of like choosing shades, and this one chooses the the color between a nook color itself
and the black color.
So we want this to be like this.
Let's set this one to one.
The alpha is the transparency of the caller itself.
So if it's zero, of course, he's going to be transparent and it's not going to be shown.
And now by pressing OK and waiting it for for it to load.
Um, it should be read within the screen.
Just give it a couple of seconds in order for it to compute.
I'm just going to save everything as well.
What can you is usually a little bit slower than working with you.
Blueprints any time you even have to make is more change, like changing the color to red.
It's still going to be taking up a bit of time.
So as you can, you can see now we have changed the color to red.
Awesome.
This is what we wanted now for our next thing.
We are going to be going back to test level just a second for it to load.
Apologies.
OK, I go in here, I right click on the Am Red Blueprint and I click on Create Material instance.
I'll just press enter because I'm fine with that name.
So what am I doing here?
In here, there is the color red in itself, which we can arguably just put on any type of color.
Sorry on any type of object and you will change their color.
But the material instance is used as a way to better organize and change the materials in our game.
So let's say that we have different parameters on the red.
So let's say that we have the base color and then we have.
Let's see.
Let's give him an emission color that is going to have a little bit of an impact on the color.
So if I click Save on the Fly, let me see what happens.
It should, like a dismissive caller, is specifically something that if we change it, it changes the
overall glow of our object.
So now nothing has changed because I've put this to a complete black.
Let's try to put it a little bit more up.
Let's see if there are any changes.
Arguably, I can actually show you what mature instances do with the red parameter if this doesn't work
for now, I don't want to go too much into this for now because it's a very simple.
OK, awesome.
It actually changed that.
OK.
So ultra safe supply.
Just make sure that all the changes that we have done are saved.
And now let's say that I do want to change.
So as you can see, first of all, the material red has changed and heats instance has changed as well.
Now, if we double click on instance, we can see in here there are two parameters the emissive color
and the red color.
If we take both of them, we now have access to their different variables and we can change them as
we please.
So if you, for example, say that the emissive color is zero, meaning that OK, I've changed the red
to blue, it's fine.
If I change the red two two zero, it actually gives us a little bit of a blue hue on the object in
this way.
I can change this parameter in here.
And as you can see here, it's actually not super visible.
Let me see if I can make it a little bit more understandable.
So there are changes.
It's just not very visible, I'm just going to go back to this and just going to put the alphabet to
zero in this way.
It should, theoretically speaking, um um, block the transparency.
OK, this is fine as well.
The bluefin itself controls the opacity of the object.
For now, it's not changing it because of the type of the object.
But again, I'm going to cover this much further down the line when we get to this for now.
OK, so we see we have the material.
Read the instance completely purple ish, but the material is still red.
So what's happening here?
So the parent red, it's in itself what is controlling the parameters that each one of these child will
have?
Let's give him the purple as well, just as an example.
So as I've explained before, we the the parent and the child concept in here, there is a similar application.
So imagine the red material as the parent of each one of these single instances.
This means that whenever any any parameter that the red has each one of these things, single instances
will inherit and will have its own parameters that then it can change, meaning that if I want to,
I can.
I can create two instances.
Let's create an instance.
From here, I can create two instances apply each one of these instances to each one of these guys.
And then I'll change the red instance one to be something else.
Let's find let's do five, five and five.
Let's see what happens.
Actually, I like the color.
Yeah, nice disco.
OK.
So as you can see here.
Again, all of these are deriving from this.
They are changing values that are already present within the parent.
But because they are changing it on then on their own, it's not affecting anybody else.
Of these instances.
If they change values within the red material, so this guy, it's actually going to change every single
one of these if they literally just remove from here this and they apply.
You can try to guess everything will become read again.
Right.
But based on their parameters, so again.
Let me just say everything first.
OK, so if they see the material instance, read here, I can only change this parameter here and I
can only change this parameter here.
As you can see, they become red again as their parent.
But they can still change the parameter that they have that the parent gave them.
So again, if they just go all the way to zero here and they save, so we have material instance, which
is the one on the right.
As you can see here, it becomes blue.
Awesome.
So in this way, we can have a very much organized and structured, raised way of assigning colors to
our objects and possibly give them parameters that we can change.
This is going to be really useful whenever we are going to be doing changes within blueprints.
OK, so now that we have a little bit of an understanding of what colors are, let's do something cool
with our little player.
So you remember, this guy is a little bit, let's say, colorless, very dull, very boring.
Let's go within blueprints.
BP play your character and let's assign him some colors.
So certain colors through any thing that again can be seen.
So static meshes are a type of actor that can, of course, have materials because they usually show
up usually used to show a specific type of model 3D model.
If there is a 3D model, of course there is a texture, and if there is a texture, of course there
is a material that we can assign and change therefore easier in materials.
Let's assign this guy the material red.
But let me find better.
Right.
Awesome.
And let's give him an instance, so let's give him the read instance over here.
And for now, it's going to be blue, but we're going to change it.
And let's give the head another different days.
So here we could, theoretically speaking, give the head the same instance, meaning that if I change
the materion instance that is on the body, it's going to change the head this well.
But of course, we want a little bit more of control of our character.
Therefore, also just simply going here and giving the other instance, which is going to be read,
for instance one.
Awesome.
Now, if you press play and we shift f one and sorry shift of one and eject, we can see that our player
is a little bit more colorful.
Now let's change that parameter that have showed you before the emissive color.
So let's go back to the parent nodding instances.
The parent, we give him back the emissive color, which again, the emissive color is what gives objects
their glow.
And we go we don't mind what this parameter looks like.
Again, these are all parameters that the child will change.
So by saving everything and applying.
OK, we see we have the emissive caller over here changing everything about our object.
So let's see oh, it actually looks like in a game just to see if it is simply like, OK, this looks
cool, actually reminds me of an image of some type of a supermarket.
OK, awesome.
We can stop the play.
So in this way we have colored our player, so we have a little bit of a level going on over here that
is still a little bit dull.
Let's create an alternate real instance.
So just to organize our code better, let's call this M and let's call it player materials.
In this way.
Any other instances of display or materials is going to be something that it's related to, the player
is just the way to divide it conceptually for us so that we can easily navigate each one of our materials.
So in this way, the player materials is going to be it's one of the player's materials and it's one
of the rare instances he's going to represent something.
So we know that the blue is the body.
So I'm just going to call this m underscore player materials because it derives from that underscore
body.
I'm going to do the same for the red instance, just pressing on on the on the blueprint actor.
I'm going to click F2 so that I can rename it and then I can simply I've copied weed control.
See here and I'll control V here, and I'll call this one.
Awesome.
So in this way, we have a little bit of more organized structure to our materials.
I'm going to do something a little bit even more organized, all creative, bolder, and I'll call it
player materials.
I'll select each one of these weed control and left click, and they'll drag all of them here and press,
Move here.
So in this way, we know that every single maturing here is going to be a material that is going to
be used and applied for the player.
Let's create another folder and let's call this level material in here.
I'm going to double click, right click, and then I'm going to be calling it creating a material parent.
I'm going to be calling this level materials.
Of course.
We are just going to be assigning to this ad base color.
Right click promotable per parameter.
We are not going to be changing this because as you saw, we don't mind what what values these are.
We mind what the child values are.
We just want to make sure that we can access these values.
I'm going to give it the best color and possibly nemesis of color as well.
Is there anything else that we may need?
I don't think so.
Anything else over here is just some of these are very simple to explain.
So, for example, varsity, as you can actually guess, it's the whole opaque our object is.
But stuff like normal or metallic or specular are used much more for textures, so they usually represent
the bumps.
So if you imagine an object if, for example, the texture of a mountain, you know a whole month and
usually have bumps.
So what 3D models usually do instead of literally just modeling those bumps in making the model overall
more hefty?
They instead make the the plane completely, um, completely plain.
Sorry for that joke on words.
And instead of trying to create any bumps themselves, they usually use a texture that fakes and simulate
those bumps.
Does bumps usually represent within the normals of the object and in themselves are also used as a way
to fake lighting?
But again, these are concepts that are should be taught to you by an actual artist.
I just have the edges of what all of these are myself because I'm not an artist.
So, OK, awesome.
We save everything.
We saved.
We go back to that level.
And here we create some instances, let's call this, so imagine that we have trees, for example.
We want all our trees to have different the same materials because of course we want the trees to be
the same color.
So right click Create Matter instance and we we call this an underscore level materials underscore tree.
We now going here and we'll create a very, very simple tree.
I'm just going to do everything within the editor.
So here I'm just going to create a boulder.
I'm just going to call this boulder trees.
I'm going to go over to some things that are much, much better down the line because what we actually
will be doing is in the BSP section, we're actually going to be creating things like these that we
can actually completely manipulate the geometry of.
For now, I'm just going to stick with something very simple because I'm just going to showcase materials
in sections, so I don't want to go too far.
So let's create something extremely amazing and beautiful.
I've just noticed I don't have is not being enabled.
I'm just going to redo this really quickly.
So they snap well together.
Chaos.
Another one.
Perfect.
And let's give him some what some what was called leaves.
Or branches, maybe.
OK, here we go.
Awesome.
So now we have a beautiful tree.
So how are we going to assign these materials to it in an organized fashion?
Because again, this is the tree materials.
And if we applied to them, imagine this is the color of the tree.
It's only one color.
So as you can see here, the the the trunk is going to be the same exact color of the branches and leaves,
and that's not really what we want.
So we can create instances of our instance.
In this way, I'm going to right click, create a material instance.
Let's say that this is the the normal material tree.
Then from the tree, we are going to derive the trunk.
And the leaves.
So let's first of all, let's do some changes over here because everything is black and it's really
hard to organize in this.
So let's go on base caller, and let's actually click on here.
So we have the color picker.
We don't need to input any weird values to try and get the color we want.
That's trying to find a little bit of a brown ish texture.
Which is arguably very hard to find here.
Let's go for something weird.
I'm just going to go like this orange, why not?
OK?
I'll say this is the is the leaves.
No.
OK, so an interesting thing we can do here is we can copy the hex linear.
Sorry, the x rg b.
These are the values that the engine uses to send collars to raw materials.
So imagine that we pick up the volume within here within this little circle sphere ish thing and the
engine converts these colors into numbers.
Then you can feed into the engine so that we can show us of this beautiful color.
So as you can see here, I've done the mistake of changing the color orange, which is supposed to be
the color of the trunk into the leaves material.
So to change this, I'm just going to be doing a copy of the RGV Hex here.
I'm going to be going into the tree trunk material instance.
I'm going to tick the base color and I'm going to click on the color picker and I'm going to be changing
these values.
The one I've copied from the other one, I'll pass OK and ban the same exact color as appeared here.
This way we can simply, you know, uh, save our changes and, you know, save our little mistakes
from happening without wasting too much time.
So the tree trunk, I like this color for the leaves are just going to be going for a really cool ring.
So I like this green.
It's just going to press, OK, uh, I'm going to save both of these.
I'm going to save materials.
I'm going to save everything, actually.
Um, let him just do his thing real quickly.
Awesome.
I'm just going to press and civil.
Awesome.
So I'm just going to sign again, this is the main parent.
I'm going to sign three leaves this, this this.
This and arguably this.
And for the to be honest, it's actually really cool with black.
This one is fine as well.
I'm going to send the treatment to these two little cubes, and now we have this little tree over here,
which we can move around to move this around with much more ease.
What we can do is create something.
So I'm just going to create an empty sort of actor.
I'm this is called target.
You usually use this just to create an instance of an actor within our scene that can give us what,
uh.
Sorry.
Transformation, rotation and skill parameters.
But what we are going to be using this for is, as I'll show you now, we're going to be using this
as the parent of our little cubes.
So I'll I'll select each one of these and they'll try to move them over to target point.
But it is giving me an error it says cannot attachments bulbous objects to target point.
Why is this happening?
It's very simple.
Right now, our static mesh is set to static static means that this object is not supposed to be moving
when it is within our game.
So whenever we press play, the game kind of knows that this object should not move ever.
So because we are setting it to study, the engine can do things with it that normally it couldn't do
with a mobile stationary objects.
One thing's, for example, so if you recall, I talked about lighting and how lighting was faked within
our textures.
One thing the engine actually does to save up on performance is actually make it so that if an object
is static, it actually bakes.
It's the term used for thinking lighting on an object.
It bakes the lighting of, say, the object on any static object.
Why?
Because because we know this object will never move.
We know that every single time we look at this object, it will look like the light will look like this.
Therefore, the engine just builds it in for ourselves whenever we press this on static.
So why am I telling you all of this?
This object instead is immovable object.
So this is supposed to move within our engine and within our scene.
But if we try to parent in object, it should not move to an object that generally should move again.
The engine doesn't let you do that if I change this to static.
Of course, the problem is not going to be there any more.
I can simply just parent everything, and as you can see, I can move them around while I'm in the engine
again.
Only when I'm playing this object will not be able to move.
And awesome, but I really want this object to be able to move because again, if we want to do some
little funny things with it, we we are not capable of doing so.
If the three cannot move.
Therefore, I'm just going to press this on movable.
And as you can see, there is no worse and you'll be you will be like, why has this happened?
Because it's actually an error.
It should change everything here because.
Let me see, actually, if I press play, there are no errors, but this one is movable and this one
are not interesting, so the the engine should change every single one of these two movable.
It did not.
Be careful of this.
It could cause you some trouble if you are doing something more serious in the future.
Let's change this all to movable.
Let's see.
And let's change, so as you can see, the pivot here, we're changing it from here to move everything
else.
Let's put it over here.
So I'm just going to parent everything one does when I pick up my target point, I'm going to move it
all the way over here and I'll move it up.
I'm just going to do a little trick, actually, I'm going to parent the target point this cube.
So it was.
Q.
Six.
Why is it?
This is a little bit of a weird issue.
So I can point this to this, but they cannot parent this to this.
I can.
OK, so the engine is actually acting a little bit weird now.
Um, let's just ignore the issues he's having.
So again, I'm going to be targeting parenting.
The target point to your six.
No, he doesn't let me do that.
Oh, it's fine.
I'll just move it myself.
Uh, and sometimes to be acting weird, so let's just try to deal with their things.
Okay, so this looks like a good position.
I'm just going to select every single one of these --.
I'm going, I'm going holding shift.
Uh, click clicking the last one and it selects every single one of them after before him.
And I'm just going to drag them over here.
And now I have control of my little tree over here using the target point that I have created.
This way I can with much more ease, control the position of this tree and move it around where I please.
Now, let's do something a little bit more fun.
I'm just going to move this trial over a little bit over here.
So let's first of all.
Um, create a bunch of.
Let's first look at a bunch of these little different trees over here.
So I'm just going to do this.
And this.
To give a little bit more love.
Love to create a little bit of a more lovely scene.
You can see stuff is more colorful and kind of nice now.
So let's do something a little bit more fun.
Let's try to change colors of the things around us by using the player.
So the idea here is that we want to shoot each one of these trees and we want to change their colors
to something different so that we can color them differently as we please.
OK, so to do so, we are going to go within our BP player character and we are going to create an event
that basically.
So let's try to analyze the logic here.
I want something where every time I aim towards a specific object and I press left, click, I want
that color of the thing that I'm looking at to change.
So that can be anything and anything in the level to do so.
We want, first of all, an event that gets called every time I press my left click mouse button.
So let's create that.
First, I go into project settings, I go into inputs and then I press on action mappings.
So the difference between action mapping and axis mapping, which is the one we used the last time,
is that axis mapping actually uses a scale, as you can see over here, that specifically refers to
the possible scale of the input we are going, we are giving to the engine.
So with the mouse, you cannot simply have an action of mouse movement.
Instead, you the way the engine set this up is that you have a variable that becomes positive or negative
based on where you are moving your mouse, which is much more simpler and a reliable way of doing it.
Instead, whenever we want to have a specific action for, in this case, a left click, we are going
to be using action mapping.
So let's press on the Plus button.
Let's go here, and let's call this shoot.
Let's find here the left mouse button.
So every time I press the left mouse bottom, you will call in action.
It will.
Give us the possibility to create logic within that action.
So let's right click and play your character blueprint top and let's find the shoot event function,
the one that we have just created.
Here we have been for press for the release, then the key variable.
So the press then released, as you can guess, are if I am pressing the left click this will be called.
If I release the left click, this one would be called instead.
The key simply to say which one are currently calling this.
So as of now, we only have the left mouse button, but we could add more of these.
And each one, any time that specific key gets press shoot will happen so we can have shoot the happening,
not simply from the left click mouse button, but also from, for example, the control key on the keyboard,
which is a way to just make stuff more flexible if we need it to be.
For now, we don't need.
We don't need it.
We just want the left click mouse button.
So input actions should again.
Let's remember what we wanted to do.
We wanted to aim toward something.
We press left click mouse button and that something changes color.
So we have the action we now need.
The thing that searches for what we are looking at to you to use such a method.
And Real has actually created a something that it's called the line trace and trace or on in other engines
are actually usually in programming called raytracing ease.
And let me just find it super quickly.
Line trees by Channel Calcium So this pretty much what it does is that it spawns a line from the starting
position to the ending position.
That gives us any sort of object that gets hit by this specific line that is upon this line is usually
invisible.
It does not is not something the user will see.
It's something that we can set ourselves to be seen using the debug type.
And in general, this is the one of the best ways and most efficient ways of gathering info about our
surrounding objects within our level in programming.
So I'm just going to link the pressed pin to our line trace.
This means that every time a person left, click my button.
This method will be called This is the outputs.
These are the outputs.
One of these tells you if it has anything.
This one is a Boolean.
A Boolean is a variable that is usually only true or false.
So if this variable is true, that means it has.
It's something.
If it is not true, then that means it did not eat anything.
The how it is simply a variable that tells us that it gives us a bunch of different parameter parameters
based on the object that we have hit to see this one better.
We can actually pull it out here and press and write, break and click on bracket results.
We boost this very close to here and then we just press the arrow.
And these are all the possible variables that we can gather from the object that we have hit.
These are going to be very useful if we want to change things about that object that we have it.
So now, uh, let's create the start and end vectors in order to cast this line.
So we want the line to be cast from the camera because that's the thing that moves around and that's
the thing that we want to use in order to.
Gather information around the world, so we what they do here.
A drug in here camera, which gives me access to any sort of variable relative to the camera itself.
I drug out the pin and then I write something called get world position.
Location, it's the same thing.
Get world location what he does, it's simple in simply function and method that similar to these.
That literally only gathers the vector.
Of the camera, the position of the camera within our world.
So if they have to symbolize this scene visually, did you see the horror, the yellow, the white dot
in the center?
That's the vector position and the vector position is represented in here by the X, Y and Z.
So what we are doing here right now, we are accessing the camera position at this current frame.
And we are going to be feeding this all to the wait to start because we want the the line trace to be
starting from the camera.
After having done this, we want to have the end vector instead to be different from the stealth, of
course.
And we want it to be based around the camera position and rotation.
So if we imagine this end line as another point here in the hour, I'll actually show you, um, I'm
creating a scene, a scene.
It's simply a in a an empty component.
It doesn't have anything apart from.
Transformer and some other little fibers that we can change.
So if we imagine this to be the ending position and this to be the starting position, try to imagine
literally drawing a line between these two.
We want this line to change based on the camera.
And I click on the com, Oh yes, nice based on the camera rotation, so as you can see here, because
the scene is a child of the camera, we can see it changing based on the camera rotation.
So just to show you this off to you, as you can see here, it changes based on the camera rotation.
So we want achieve this exact effect.
But within blueprints to do so, we can use the forward vector of the camera, which is this one, and
simply adding this to our starting position plus multiplied by a scale factor that simply makes this
vector bigger, which is going to be actually the range at which we can see things further from us.
So let's put this to the test in the camera, we pick up the get forward vector.
This is not needed, we pick up the get for Vector, so we are picking up the vector that comes from
forward of the camera, this one will pick up on the rotation as well.
And we multiply this by a set amount.
Let us usually end in this way and let us press that right click and promote the Bible.
So what I'm doing here, I'm creating actually our first Bible, which is an integer.
An integer is simply, am I for?
No, it doesn't have any comma.
It's simply an integer value.
So one two three four five a float instead would be a number that actually can have a comma.
So one point two will be a float and one would be an integer.
You can have one as a float of if we want to do so, but that's beside the point.
Um, OK, so we are multiplying this by this.
We are going to be calling the integer, let's call it range, because that's kind of what it represents.
And will then add the starting position to the vector that we have just created.
So simply pressing plus and doing a vector plus vector, I'm just going to pin this all the way here.
If you hold OLT and you press on any pins, it just unplugs them.
It's a very handy way of doing things.
We then add these two vectors together, so again, we're adding the get forward vector with the get
world location of the camera, meaning that the result of this is going to be a vector that is going
to represent the ending position of our line trace.
So again, the scene, the this little thing is what is going to be happening behind the scene.
So we are going to create this position.
And related.
And we'll connect this to end.
No.
How do we know that we have done everything good?
Well, it's very simple.
Over here, we have a different options that the Line three gives us the possibility to access.
I'll just pick click on the line over here.
And so we have visibility, which is something we don't really mind.
Visibility is usually the default.
We'll just stick with it for now.
Trace complex again, we don't really mind this.
This is mainly to um, I mean, as you can actually read as well.
True to test against complex collision falls to test against simplified collision, the complex collision
is something related to objects.
This box over here has a simple collision because the collision it is using is the default one of a
cube.
But if something has a much complex, more complex collision, so let's pick up this tree, for example.
Right now, this tree?
Well, everything here is simple collision because it is created of objects that are of a similar collision.
But if we are creating one collision for this entire object, then you'll see that the collision will
actually change to a shape that does not represent the cube anymore.
And because it does not represent the cube anymore, it won't be a simple collision anymore.
And this force, this boolean actually tells us if if we want to ignore more complex objects or not,
we don't mind this too much for now.
So I'm just going to leave it that false.
But of course, later on down the line when we will have more complex objects in the scene, I'll show
you how this can be used.
So false actors ignore this one will skip for now, but basically it just it's just a way to tell him
to ignore so that the line when passing through things, it will just ignore some actors, literally
the dirty bug type.
It's what we are actually looking for here.
I'm going to click on for duration.
So the way this works is pretty much we have these three options for one, frame for duration and persistent
for one frame.
It literally means that the line that we are going to be creating to, um, visually is going to last
only for the duration, which is shown over here.
For one frame, that means that it will only last for one frame and persistent means it will last forever.
So I'm just going to stick with it for duration for now, just to show you off.
Ignore self always.
Yes.
This usually means that it's just ignoring it's itself.
It's not counting itself as a hit, which you usually don't want that to happen.
This is the color.
Let's leave them at this for now.
Oppressive press play.
And now every time a press left click, something should happen.
Nothing is happening, which is weird.
Let's go check what's the issue?
So if we don't know if this event is happening, we'll simply going to use a ring to shrink.
To make sure that this Arantes happening, I'm just going to unplug everything else while safe.
So the idea here is that maybe what's not working is the lane trace itself.
I'm going to use a print string, meaning that if I press left click and it says hello.
I mean, that means the introduction is working, so the problem should be in here.
So, OK, it seems that this one is working.
Whoops.
I just press the button.
Don't mind that too much.
I just pressed F1.
So if this if this happens to you as well.
F1 just shows you the collision of each object that the vertices and their specific messages if you
press two or three or four a day changing different things.
What you want to have is F3, which is the usual one we are always using the one that we currently use.
If you do a mistake like that, don't panic.
Just press F3 and you're good to go.
Or you can simply close and open up the play again.
So I press F1.
Oh no, I don't know what's happening.
I press ESC, I press play and everything is back to normal.
OK, so the problem is not in production.
So the problem must be within the lines race itself.
Let's see what we did wrong.
So we know this one is working.
Let's try to put the duration to persistent and let's put the trace to.
These are fine.
These are not going to cause issues.
OK, let's see.
What's the issue here.
OK, it's not showing anywhere there could be some reasons for this to happen.
Let's check a little bit.
Um.
The positions that we are giving him.
Actually.
So I'm going to do something to test this out a little bit.
I'm going to use another method I'm going to spawn.
No sponsored actor from Plus.
OK, so I'm going to be spun into an actor.
On the position that is shown at the end and at the start.
So in this way, what of our alliance race?
So in this way, what I'm doing is.
I was on a random object at the start position of the camera so that I can see where the starting position
is happening and if there are any errors, if the object spawns right where we are, then everything
on the start side is working as we as it's intended.
If it's not, then there is something wrong and we need to fix it.
So as of now, I am going to give him a glass, so lets you choose something random.
Uh, let's see.
Maybe I can create myself something random.
Uh, I'll go in blueprints I'm going to have in class.
So going actor, I'll plate something random just to test this out.
I'll give him a static mash.
And I'll give him I'll change is static mesh to acute.
OK, awesome.
In this way, whenever I press the left-click, it should do a line trace and then I should spawn an
actor to the position that I'm going to be giving him.
So you see here it is asking for a spontaneous form.
Usually, a sponge runs from ease.
As you can see over here is the unification of location rotation a skill?
Of course, we can simply go in here and we can right click on split struck pin.
And now we can see each one of these that it is going to spot us.
So the rotation we don't care as well as the scale.
We don't care.
We only care about the position because that's the one we are using here.
So if like press, if I just copy these and pull them over here and I'll plug them in here, I'll compile
or see if it is giving me, oh, forgot to choose the class something random.
Awesome.
So if I know, press play.
And I hear you go you can actually see within the game, I I clicked left click and it exactly spawned
a cube right where my head is.
So if I click on the cube, the the widget is exactly in my head, which awesome.
That means everything is working or settling over there.
Uh, let me see the ending position instead.
So let's spawn.
Oh, wait, I'll keep doing this.
And then I have just realized that's the issue.
You probably have realized as well because they actually showed that.
But let's keep doing with this because it's really good to just debug stuff and know how to debug stuff.
So.
We do not code.
So I'm going to be copying the entirety of this other operation that we are doing.
So the output is this one.
I am going to pick this up, put it in the phone, transform, press, compile safe.
Now I'm pressing play.
If I press left, click, Oh, would you look at it?
The thing?
Oh, no.
All right.
Press play.
So the object has spawned exactly what our ad is, which is weird.
We did not want it to spawn here.
We wanted it to spawn something a little bit further from us so that something like here, this is happening
because we are actually not giving him a range, meaning that this range right now equals to zero.
And because it's a multiplication, it's completely nullifying this forward vector, meaning that the
only thing that this addition is going to give to the end position is the starting position.
Meaning that doing this with this value is of zero.
It's the same exact thing and simply at simply doing this, so giving the end the the same exact location
as the start.
So how do we fix this?
Very simple.
We have the range of here already.
We simply just need to change its value.
So let's give him a value of 1000 as an example.
We can no, I'm just going to unplug this, so in case there are any other errors, we can actually
use this till I because I haven't deleted it.
So right now, everything should work fine.
I press play, I press left click and you can see the line is very thin, but we can see that it is
costing from our ED all the way to the center of the camera and it is eating the first thing he sees.
The color green that we see here is the line that tells us, look, I had hit something so.
As you can see.
It is telling us that it is hitting this cute.
If I do it over here.
Same thing applies.
And if I do it over here, same things place awesome.
So the line trace is working, I can now delete this because I don't need it anymore.
I have debulked, my code and I have successfully found the error.
And now we have the shooting, we have the lane trace now what we want to do is we want to change the
material of the object that we hit.
So to access the object that we have hit, we can simply use this variable over here.
That is the hit doctor are the hit doctor is a reference to Doctor that we have it to the to the line
channel.
So before we do this, let's actually create a branch.
Let's make sure that we have it something first.
So I'm going to be clicking holding down.
Be.
And pressing left, click this Create it branches.
This is a quick way of doing it, the way normally you do it is you go in here, you just write down
brunch, but a quicker way of doing it, simply holding down and pressing left.
Click my button.
So what is a brunch at?
Brunch is something extremely simple yet extremely powerful.
The brunch is an if statement which asks you a condition with which, if this condition is true, it
splits up into true or false.
So if the condition we give him is true, the code is going to go in this way and it is going to ignore
anything else that this year.
If it's false, of course, it's going to ignore everything within the true business and just execute
the one in the false bits.
So the condition we're giving him is asking him if we have it at anything.
So if we have anything, then do the true.
If we have not hit anything, then do the false.
Of course, we can just keep these completely blank like we don't need to plug anything here.
If it's false and then there is nothing plugged here, the code would just stop and we'll circle back
to the next frame without any issues.
OK, so now we know, possibly if we hit something, we need to access the actor that we have it and
we need to change its material, so.
In the case, we hit something.
We are going to.
Use a method called set material.
Which is a method that, as you can guess, sets the material of something.
And we are going to give him as the target, the hit actor.
So the problem here is that it's asking for a component.
We don't want a component.
We want an actor.
So there are different methods for each object.
There is a method for actor.
There are methods for actors that are methods for components, sometimes to understand why stuff is
not linking well together.
The only thing you need to do is literally hover down with your mouse over here and check what it is
asking us to do.
So right now, we see that once a component, not an actor.
And if we don't fully understand what the component is, we can simply promote this to a variable.
And you can see the thing it is asking us.
It's literally something similar to our head, our body or our camera, which are components of an actor,
not the actor itself.
To fix this, Phyllis, first of all, delete the variable that we have just created.
Let's delete this method and let's drug all the way from hit doctor and let's write down set material.
If we don't find it, we remove the context sensitive and we check for the settlement hearing here.
And there it is.
Again, it is giving us issues, so I suppose there is not a method for changing the material of a specific
actor.
There is only a method to change the material of specific components, which is just a case of not having
that seed method.
But sometimes some methods do have are different based on if they are trying to go for actors or if
often trying to go for components.
We don't mind too much the fact that it is asking us for a component.
We'll just give him the component we because we don't really mind.
Again, when I press the cube, the only component of the cube, as you can guess, it's the static
component.
So whenever I shoot and I hit the static mash component, I am accessing his material and I'm changing
the material.
And because it's only one thing I am hitting that is perfect because it won't give us any issues.
So this metal would do just fine for us.
OK, so.
We are linking this, giving him the target of what he needs to change the material of as our component
that we have hit with our line trace.
We give him the element index is simply so if you have different materials for one single component,
all you need to do to access each one of these materials singularly is give the method a set material,
the index element shown in here.
So you see this is the element zero.
Therefore, we are feeding him the Element Index zero.
If there were if there were more materials or elements, rather we would give him the specific number
of that material.
And then we select the material that we want to change the material of that we want to swap it with.
So the material is going to be this means that every time we hit something, we are going to change
the material that something to the material that we are.
We are going to be deciding and choosing in here.
Uh, let me let me see.
So.
Let's create.
A material.
Let's just give him for now for testing the M level materials, three lives.
So I'm just going to have to copy the name.
I'm going to play a character, I'm just going to close these guys out because they are annoying me
a little bit.
Bring down the tab here and I'm just going to search for the leather materials tree leaves compile safe.
Now, let's recap very quickly, and then let's see if it works.
So we are casting L.A. in a line coming from the camera all the way to the end of our vector that we
have decided through this operation.
And we're here, we are creating this line and anything this line hits.
Is going to change the material of that thing, specifically, if it hits something, it's going to
change something.
If it doesn't hit anything, it's not going to change anything.
OK, awesome.
Now I am going to be going to the test level when I press play.
I'm going to aim a camera towards the subject.
I'm going to press the left-click hand.
There you go.
It is changing its material to the one that we of the leaves.
So I can now go around and literally just call out the entire area.
These are already lives, so it's not doing anything.
And as you can see, everything is working as intended.
If we are too far away.
Oh yeah, I can use the floor actually if you are too far away.
It won't work because we have set up his range to be 1000 units.
So eventually, as soon as I managed to get him to range in the press, the left-click most bottom are
you go, it's changing its color as well.
We can change the color of pretty much anything with this.
A password for this, for some reasons, which it's weird.
But yeah.
Uh, awesome.
And this way we can clear up the entire zone of green because we managed to set up this little code
things within our project.
So what are we going to be doing next in the next video?
I'll show you how to.
We are actually going to be creating a little bit more gameplay right now.
We can color things, that's for sure.
But still, there isn't really a game here.
We can just call her stuff, and nothing really happens apart from this.
So in the next video, I'm going to do something a little bit more fun.
I'm going to be doing something where you can pick up the color of something that you hit with, for
example, the right mountain, the right click of the mouse button, and then you can put that color
on somewhere else.
And in this way, if you, for example, make it so that the color of the tree is the same color of
this tree, a door will open and you can continue.
And in this, we will have a little bit of gameplay and a little bit of goals for the play.
You have to train the chief.
And I'll also show you how to create a little level using the BSP geometry tools that are real.
Give us the access to and in this way will start to create our very first video game in a real.
So thank you for tuning in and I'll see you in the next video.