in this video we're going to talk
briefly about execution order within
blueprints so let me show you the
blueprint that I've constructed to make
this happen it's pretty simple I hit
play and as I'm playing I can hit the e
key and if you look in the upper right
hand corner of the viewport it's
reporting the direction that I'm facing
so right now I'm facing East uh then I
can fa face Southeast South and so on so
let's take a look at the graph that is
making this happen so I'm going to pull
this over now I have really heavily
commented this graph so I want to take
just a second and walk you through it
and then we'll talk about the specifics
of execution order so basically you
press the E key uh we are getting the
rotation of the character we're
offsetting that by 22.5 degrees and what
that does is that takes uh the overall
Rotator which by the way runs but from
uh 0 to 180 in One Direction and 0 to
negative 180 in the other direction and
it uses the positive or negative value
is between 0 and 180 to figure out what
way you're facing so what we did is we
rotated that whole coordinate system by
22.5 de and that way we can have a 45
degree quadrant that is perfectly upward
facing without having to worry about
that funny uh switch you get between 359
and zero so then we uh break that open
and we grab just the yaw because we just
want to know which way the character is
facing and we create a simple condition
using a select float so we have just the
the actual value of the yaw on the one
hand and then we're also taking that
value and adding 360 to it and this is
for those instances where yaw Falls
underneath zero so uh for instance 90 is
the same as 270 degrees if you were
thinking about it like in terms of a
compass heading so what we're doing is
saying if that value uh is greater than
zero then we want you to just use the
raw value so just uh you know if if the
uh the direction happens to be I'm sorry
if the yaw value is say 90 degrees just
use 90 if it turns out to be90 then add
360 to it so that we end up with the
proper value of uh 270 in this case
which is useful just in our purposes now
once we have that we end up with a full
360° rotation value uh for a character
we divide that into 45 degree segments
and we round it down to the floor now
that's going to give us an integer value
we then use a switch on int and
basically whatever int is fired in here
which is going to be uh 0 through 7 we
use that to drive an En Ator now really
quickly I'm going to show you this
enumerator if I drag my graph out of the
way can open this up it's just a simple
enumeration you can create these in your
uh in your content browser by right
clicking and going under miscellaneous
and there's an enumeration so it's just
you can see it's the eight cardinal
directions uh all in order so North
Northeast Etc and so on so once we have
those we created a variable in our
blueprint using that enumeration and So
based on what integer we find we are
outputting some direction finally all we
do is print out the result of that
enumerator so overall it's a pretty easy
setup uh but there it does call into
question exactly how things get executed
because it's really easy to say well
blueprints operate from left to right
which is true you know they're going to
have inputs on the left they have
outputs on the right but sometimes your
graph does something like this where
you've got a lot of nodes way off to the
left so what is the order in which
things happen well when you hit the e
key this is going to take place okay
you're going to get your your uh your
pressed event and that's going to hit
your switch on int now in any case where
you have an input coming in from a
non-execution wire so basically any
function that has to feed data into a
value what's going to happen is unreal
is going to take a snapshot it's going
to basically trickle all the way down
reach all the way back to the back of
this uh of this wire group and it's
going to take a snapshot of all these
values for this one moment in time and
then it will solve the math that is
required so it it stops for just a
second and it grabs all these things and
says boom okay what are you guys doing
right this very moment so that's when it
actually walks through and grabs the
rotation uh handles the the rotation of
the coordinate system so that we you
know in soad everything works well and
then figures out whether it was greater
than or less than and chooses the
appropriate value based on the select
float it does the math to divided into
uh eighth sections and then rounds that
down and then it has the information
that it needs so then it can perform the
switch on int and based on its value it
chooses one of these wires so let's say
for instance I was facing well I ended
up with a value of zero then that's
going to fire off my output zero that's
going to set my enumerator to a
direction of North and then that is
going to call the print string now the
print string is also waiting for an
input so he's going to reach backwards
as well he's going to go all the way
back to the end of the chain and take a
snapshot and then perform whatever
operations are needed to satisfy these
criteria so he's going to take the
direction en he's going to convert its
output to a friendly string uh you mean
see the tool tip says returns user
friendly name of the enumerator so it
converts that to a string plugs that
into the print string and then we get
our result so just to play back one more
time now when I hit play and I hit
e again you see what's happening but
what I'm going to do real quick is we'll
back
out and I'm going to try to kind of make
the most of my uh my UI here so actually
let's pull out the viewport because we
can do that so I'll take the event graph
here and we'll put that on one side and
line that up actually you know what I'm
sorry let's do this a slightly different
way let's make since this is such a wide
graph we'll make the graph nice and wide
so we can see pretty much all of
it there we go and I'll pull this stuff
off screen because we don't really need
it uh let's go ahead and rip off the
viewport and I'll just shrink that down
up
here so now we can just hit alt p and
play and now each time I hit e you can
see the different enumerator wires
firing as I turn
around all because we're getting that
different integer value and what that
means is all of those wires to the left
all those nodes must execute so now you
know how this execution order thing
works essentially so you have all of
these nodes that don't have execution
pins on their own but they are feeding
an input so what unreal is going to do
is take a snapshot of their current
state solve all of the equations that
they basically spell out and then use
that to produce the input so that it can
move on with the rest of execution
that's going to wrap things up for this
video thanks a lot