so in this video I want to talk briefly
about variables give you an overview
kind of an idea of what they are and the
ways you can go about creating them so
first off what is a variable well really
it's just a way to store data this data
can be anything it can be a number it
can be a name it could be an actor that
happens to be in your level lots of
different things we'll talk about the
different types that a variable can be a
little bit later now the reason you want
to store this data is in case you it for
any reason want to access it later so
for example if you know you're going to
need to change a value or you want to be
able to read a value like maybe figure
out what is the current value of this
number you know that you'll need to
store it in some kind of a variable it's
also important if you need to send some
bit of information some data to another
graph within your blueprint or to
another blueprint altogether so for
example if you need to send some type of
value between the construction script
and the event graph then you need to
store that data in a variable so that
both graphs can easily access it also if
you ever have some bit of information
that you may need to send to another
blueprint for example if you have a
blueprint that has a character's health
and you need to report that health to
the level script or to another blueprint
for any reason whatsoever then you're
obviously going to want to store that in
a variable an easy way to remember it is
really any piece of information any
piece of data that is that seams in any
way important to you should almost
always be in a variable actually let's
just say it should always be in a
variable the more you start to work with
blueprints the more you start to
possibly come across instances where you
realize you're only going to use a piece
of information once and at that point
you can just start connecting wires but
even then it's often easier to read and
easier to work with if you'll just go
ahead and store things in a variable for
later now one other rule I do want to
mention before we go on to creating
variables is that all variables in
unreal must have a variable type or a
data type if you're coming to this from
any programming language and they can
only have one type now I'm going to talk
about the specifics on data types in a
separate video for now just keep that in
mind that you have to assign a type to
all of your variables now let's jump
over to on
real and we'll talk a bit about creating
these variables so I'm going to go into
my blueprints folder here my project by
the way this is just a basic
third-person blueprint template let's
click on new and I'll create a new
blueprint from actor and we'll just call
this variable workshop and I'll go ahead
and open this up so I don't really need
any sort of components to do what I want
to do but in case I want to bring this
in to the level I am going to add a
billboard this is just so that I can see
the blueprints if I add it to the level
now let's jump over to the graph I'll go
ahead and make this full size now
creating a variable is a very simple
thing you can just click on the add
variable button and you can decide a
name right away so I'll call this my
variable and next you will have you'll
see the details panel appear down
underneath your my blueprint tab by
default that will have the name for the
variable which you can change if you
need to and you also have the variable
type and this is that data type I was
talking about a little while ago again
not going to get into all the different
types here that's something that we'll
talk about in a separate video so now
that this blueprint I'm sorry now that
this variable is created I can bring it
into my graph at any point just by
dragging into the graph this will open
up a little submenu asking if I want to
get this value or set it to something
and I'm going to talk about the nuances
of getting and setting again in a
separate video we'll try to keep this
nice and by bite-sized but for now I'll
just go ahead and choose get and there
is my variable so I could do things with
it I could in this case use it maybe to
drive a branch or things of that nature
now there's another very popular way to
create a variable and that is to promote
it from some other operation in your
level a really easy way to show this off
would be something like say if we had a
math operation so let's say float plus
float now just off the top of it just to
kinda help you out a float is any number
with a decimal point so if I said I had
five point one or five point three one
because that's what my fingers hit plus
six for example and I know I want to
store that result as a variable I can
right click on this data output pin and
I can choose promote
to variable that will automatically
create a variable that is asking for a
name already so I just call this math or
maths answer just in case there happen
to be any British folks watching
so we've now stored that in a variable
notice however this create a set node
and this set node is going to require
some sort of execution input in order to
fire now the more you get into
blueprints the more you'll get used to
seeing these execution wires if you
don't understand how those work you
should probably just grab some of the
getting started blueprint videos that we
have lying around or we could say
something like begin play so as soon as
the game starts we immediately set that
that execution wire just controls when
things happen now notice that set node
was created because I right clicked on
an output value but you can also right
click on an input value and choose
promote to variable and we could say my
plus this will be the name of my
variable in this case and notice it
automatically created a getter and
created the variable for me so if you're
unsure as to what type your variables
going to need to be in on in many cases
it's often easier just to create
whatever it is you need to have happen
and then take what its input words
output and promote that to a variable or
of course you can just click on the add
variable button so that is going to wrap
things up for this video thanks a lot