WEBVTT

00:06.810 --> 00:07.860
Welcome back.

00:07.890 --> 00:15.120
Now we'd like a behavior tree specific to the shaman, but for the most part, I want things to be pretty

00:15.120 --> 00:16.350
much the same.

00:16.350 --> 00:18.630
We're just going to change a couple of things.

00:18.630 --> 00:22.800
So the first thing I'm going to do is duplicate this enemy behavior tree.

00:22.830 --> 00:28.500
I'm just going to right click on it and choose duplicate and I'm going to call this BT Behavior tree

00:28.500 --> 00:30.180
underscore Shaman.

00:30.180 --> 00:32.580
Really, it doesn't have to be that specific.

00:32.580 --> 00:39.870
We can make it elementalist as we could have other enemies that are elementalists that are not shamans.

00:39.870 --> 00:45.990
So now that we have this behavior tree, I'd like to go into my shaman and change the behavior tree

00:45.990 --> 00:50.210
to the Elementalist version and just make sure that this still works.

00:50.220 --> 00:56.160
Now all it's doing is trying to activate abilities with the attack tag, and our shaman doesn't have

00:56.160 --> 00:57.720
an ability with the attack tag.

00:57.720 --> 01:00.000
It just has the summon ability.

01:00.000 --> 01:03.420
So I'd like it to have that ability so we can see it attack.

01:03.420 --> 01:09.880
So we're going to go into blueprints, ability system data, the character class info and go into our

01:09.880 --> 01:17.140
elementalist and make sure that it's startup abilities not only has summoned ability but also the attack

01:17.170 --> 01:17.770
ability.

01:17.770 --> 01:23.230
So g A and this is going to be the actually firebolt ability.

01:23.230 --> 01:27.550
But we need enemy firebolt the one specific to enemies, right?

01:27.550 --> 01:30.610
So now it has summon and enemy firebolt.

01:30.610 --> 01:38.590
And since it's using the new enemy behavior tree, which is just a duplicate of the old behavior tree,

01:38.620 --> 01:43.360
we should see the same behavior that we saw before we made our summon ability.

01:43.360 --> 01:46.960
In other words, our shaman should launch fireballs at us.

01:46.960 --> 01:51.430
So let's save all and press play and see if that's the behavior we get.

01:51.430 --> 01:52.690
And we do.

01:53.190 --> 01:55.170
Now we have an issue here.

01:55.500 --> 01:59.880
It looks like we're getting a premature explosion.

02:01.610 --> 02:05.190
It looks like we're exploding a little early here.

02:06.060 --> 02:09.080
So let's go ahead and see what it is we're hitting.

02:09.210 --> 02:16.320
I'm going to go into our actor folder and open ora projectile and we'll just place a breakpoint right

02:16.320 --> 02:18.420
away in on sphere Overlap.

02:18.450 --> 02:20.690
Let's see what it is that we're hitting.

02:20.700 --> 02:22.200
I'm going to press play.

02:23.180 --> 02:28.430
And right away we can check other actor and I see that it's one of the tiles.

02:28.430 --> 02:35.000
So we might actually be spawning that projectile a little bit too close to the ground.

02:35.180 --> 02:41.300
So I'm going to remove that breakpoint and resume and let's see if we can tweak things a little bit

02:41.300 --> 02:43.280
so that we don't get that overlap.

02:48.210 --> 02:57.800
I'm going to open Blueprint's ability system or a abilities fire and Firebolt and open up Firebolt.

02:57.810 --> 03:00.210
Let's take a look at its sphere.

03:00.360 --> 03:02.370
It's a little bit large.

03:02.370 --> 03:08.670
I like that it's large, but we can make it a little bit smaller and see if that fixes the problem.

03:08.970 --> 03:10.530
Let's just see.

03:13.580 --> 03:15.740
And it looks like that fixes the problem.

03:15.740 --> 03:22.970
And even though it's a little bit easier to miss, I think that that's okay.

03:23.720 --> 03:30.020
Our little shaman guy is just so close to the ground, it's hard to have such a large sphere there.

03:30.790 --> 03:37.300
An alternative is to disable collision on the sphere for the first, say, 0.5 seconds or so.

03:37.330 --> 03:44.200
That way it kind of passes through everything for the first bit of time before moving on.

03:44.230 --> 03:46.630
That might be something we could try.

03:46.720 --> 03:51.230
We could go to our event graph and an event begin play.

03:51.250 --> 03:56.740
We could set a timer of sorts and enable collision then.

03:56.740 --> 04:01.570
And then our sphere could be set to no collision from the start.

04:01.600 --> 04:03.120
Let's see if that works.

04:03.130 --> 04:06.340
Let's go to collision enabled.

04:06.370 --> 04:09.250
We want it set to query only shortly after spawning.

04:09.250 --> 04:09.790
Right.

04:09.790 --> 04:16.880
But we can set it to no collision first and set it to query only here after a short delay.

04:16.900 --> 04:19.030
So we could say delay.

04:20.200 --> 04:22.750
We'll leave it at 0.2, maybe 0.5.

04:23.020 --> 04:27.250
And then we can set the collision enabled for the sphere.

04:27.400 --> 04:28.420
So set.

04:28.420 --> 04:31.390
Collision enabled.

04:31.420 --> 04:33.640
We can set it to query only.

04:34.650 --> 04:40.800
And I'd like to see exactly where the fireball is in relation to its spawn point at this point in time.

04:40.800 --> 04:42.420
So I'm going to draw a debug sphere.

04:44.540 --> 04:48.860
And I'm going to draw it at the location of this actor.

04:48.860 --> 04:50.420
So get actor location.

04:54.040 --> 04:56.050
And I'm going to get the sphere.

04:58.300 --> 05:00.220
And get sphere radius.

05:00.490 --> 05:03.880
That's going to be the radius for my sphere that I draw.

05:04.150 --> 05:05.410
I'm going to make it red.

05:06.630 --> 05:12.930
I'm going to let the duration be five seconds and let's just see what happens here.

05:13.200 --> 05:17.440
Now, compiling isn't going to work because Sphere is not blueprint visible.

05:17.460 --> 05:19.530
We have not exposed it to the event graph.

05:19.530 --> 05:28.650
So just really quickly, we have to close the editor and go into Aura projectile dot H and we have to

05:28.650 --> 05:30.180
expose the sphere.

05:30.210 --> 05:36.240
Now that means we either have to move it into the protected section or get around having the private

05:36.240 --> 05:38.940
variable with a meta specifier.

05:39.060 --> 05:40.080
Here's what I mean.

05:40.080 --> 05:46.110
If we wanted blueprint read only and we want to keep Sphere in the private section, we'd have to say

05:46.110 --> 05:49.650
meta equals allow private access.

05:50.810 --> 05:51.800
Equals true.

05:53.450 --> 05:57.770
That's how you get around having a blueprint read only and a private section.

05:57.770 --> 06:02.540
But rather than doing that, I prefer to just move it into the protected section.

06:02.540 --> 06:09.230
And that way we don't have to make it private in C plus plus but exposed in blueprint.

06:09.260 --> 06:12.590
We're just going to make it a protected variable.

06:13.250 --> 06:19.670
So now that the sphere is exposed, we can now launch the editor and use it in the blueprint.

06:21.450 --> 06:23.940
So we'll go ahead and open up that blueprint.

06:23.970 --> 06:28.680
We see that it compiles just fine and let's see what happens.

06:33.320 --> 06:40.610
Okay, so that half a second is a bit long because if I'm closer than that, that fireball passes straight

06:40.610 --> 06:41.360
through me.

06:42.040 --> 06:45.250
So this is kind of a long delay.

06:45.280 --> 06:48.250
Let's try 0.1 seconds and see how that looks.

06:48.250 --> 06:51.100
That should be a fifth shorter.

06:51.430 --> 06:52.120
There we go.

06:52.120 --> 06:54.400
So if we're too close like this.

06:54.400 --> 06:55.240
Close.

06:57.580 --> 06:59.570
Then it should pass through us.

06:59.590 --> 07:02.170
I guess we're still going to get hit.

07:03.780 --> 07:05.310
So that's still okay.

07:06.950 --> 07:07.940
Now let's see.

07:07.940 --> 07:10.220
I hit stop and we get a blueprint.

07:10.220 --> 07:17.390
Runtime error attempted to access sphere via properties Sphere but sphere is not valid pending kill

07:17.390 --> 07:18.530
or garbage.

07:18.530 --> 07:21.290
And this is in draw debug sphere.

07:21.290 --> 07:25.340
So that's going to be for draw debug sphere.

07:25.430 --> 07:30.020
We can always avoid that kind of error by doing a validated get.

07:30.020 --> 07:33.770
So we can right click on sphere, we can convert to a validated get.

07:33.770 --> 07:39.380
And this is like checking if a pointer is not null or rather checking is valid.

07:39.380 --> 07:44.570
So even if it's not null but still pending kill we won't make it past this.

07:47.940 --> 07:49.740
Okay, so things still work.

07:53.610 --> 08:00.570
And if I'm really close to the enemy and I fire over there, well, I guess that's kind of beyond the

08:00.570 --> 08:01.530
reach of it.

08:04.910 --> 08:06.230
But this is looking good.

08:08.440 --> 08:15.640
So again, we're attempting to access sphere when it's not valid and that's only when drawing the debug

08:15.640 --> 08:16.420
sphere.

08:16.780 --> 08:22.570
But before we get rid of the debug sphere, I'm going to take my sphere and increase its radius.

08:24.210 --> 08:31.650
That way we can see if we can have a bigger radius without worrying about a premature explosion.

08:31.770 --> 08:34.770
Let's see this happen in action.

08:37.480 --> 08:38.110
Great.

08:39.520 --> 08:44.590
So now it's not so easy to miss and we still have a little bit of a delay.

08:49.750 --> 08:50.650
Excellent.

08:51.190 --> 08:51.550
Okay.

08:51.550 --> 08:54.690
So I'm going to remove that draw debug sphere.

08:54.700 --> 09:02.170
We don't need that anymore and we now have a slight delay before enabling collision for the Firebolt.

09:02.200 --> 09:02.560
Okay.

09:02.560 --> 09:08.200
So all of that just so that we could have the same behavior as we had before, right?

09:08.230 --> 09:17.890
We have a firebolt wielding shaman and really, you know, that's really all it does is launch firebolt.

09:17.890 --> 09:20.750
But we want it to summon as well.

09:20.770 --> 09:29.080
So what we need to do is we need to put some custom functionality in our behavior tree specific to the

09:29.080 --> 09:33.100
Elementalist and we'll do that in the next video.

09:33.280 --> 09:34.150
It's a great job.

09:34.150 --> 09:35.260
I'll see you soon.
