Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:03,820 --> 00:00:09,940
Now, in this video, you want to be able to get these enemies to respond, even if they attack you.
2
00:00:10,600 --> 00:00:15,790
So in our scripts, obviously we've got our damage, but we've also got our main need, the two scripts
3
00:00:15,790 --> 00:00:16,750
to talk together.
4
00:00:17,380 --> 00:00:18,730
So what we got Aspelin points.
5
00:00:18,730 --> 00:00:24,300
We need to change our public into zombies on screen to a public static so that it can be accessed by
6
00:00:24,310 --> 00:00:25,090
other scripts.
7
00:00:25,960 --> 00:00:32,230
Public static is one is a variable that gets saved in RAM in actual memory on your computer.
8
00:00:32,830 --> 00:00:35,890
And so exists outside of any one script.
9
00:00:36,740 --> 00:00:38,770
And that's good.
10
00:00:39,080 --> 00:00:43,060
It can certainly save it between between levels and all sorts of stuff.
11
00:00:43,900 --> 00:00:48,130
In a way, it's good, but in a way it's also bad as well, because you do have to reset them.
12
00:00:49,300 --> 00:00:50,530
You have to remember to do that.
13
00:00:52,120 --> 00:00:53,260
We'll get into that later.
14
00:00:53,860 --> 00:01:00,280
OK, public static game objects as well, so we can access these from the other script.
15
00:01:02,500 --> 00:01:09,460
So we've got public static zombies on screen, Butson screen, Gelson screen and make these public not
16
00:01:09,460 --> 00:01:13,840
private, sorry, public, static.
17
00:01:14,920 --> 00:01:16,330
Otherwise they won't be available.
18
00:01:19,270 --> 00:01:23,120
Public static game objects of lust destroy zombie last destroy Bakhtin.
19
00:01:23,140 --> 00:01:24,580
Last destroyed ghost.
20
00:01:25,820 --> 00:01:33,490
OK, now over in our damage, you can say if the other object is just this, this is a bat and we can
21
00:01:33,490 --> 00:01:40,930
say main dart bats on screen is minus minus.
22
00:01:41,890 --> 00:01:49,540
We can also say may dart and blast destroyed.
23
00:01:49,540 --> 00:01:57,110
Bat equals the dart game object.
24
00:01:57,130 --> 00:01:59,050
So the dart.
25
00:02:02,120 --> 00:02:02,930
Game object.
26
00:02:02,990 --> 00:02:03,530
There we go.
27
00:02:05,480 --> 00:02:07,760
So that will then place that into that slot.
28
00:02:07,880 --> 00:02:12,710
OK, so let's just that let's take all this control.
29
00:02:12,720 --> 00:02:21,890
See, let's do the same on Ghost and just change this to last destroyed ghost and ghosts on screen.
30
00:02:25,730 --> 00:02:27,620
Let's do the same for zombies as well.
31
00:02:29,960 --> 00:02:34,850
Last destroyed some bee and some bees on screen.
32
00:02:40,410 --> 00:02:42,980
Now, that should get some response.
33
00:02:43,560 --> 00:02:45,960
Let's just double check this to make sure that this works.
34
00:02:54,190 --> 00:03:04,540
So why wait for some of these creatures to actually hit my character, who was born in different points
35
00:03:04,540 --> 00:03:05,350
throughout the game world?
36
00:03:05,920 --> 00:03:07,990
So I'm constantly asking me.
37
00:03:14,710 --> 00:03:15,010
Good.
38
00:03:15,310 --> 00:03:16,210
All right, that's working.
39
00:03:16,480 --> 00:03:19,690
But now we need to get these images to actually turn on.
40
00:03:19,990 --> 00:03:27,160
So for this back in the main, you know, give myself a comment.
41
00:03:27,160 --> 00:03:29,920
So let's call it player damage.
42
00:03:32,710 --> 00:03:34,060
We need a few more variables.
43
00:03:34,090 --> 00:03:38,600
So first of all, we need some kind of a ball.
44
00:03:38,650 --> 00:03:43,840
So I'm going to once again make this a public static so it can be called from the other script of type
45
00:03:43,840 --> 00:03:50,590
boolean or call zombie attack equal to false to begin with.
46
00:03:51,800 --> 00:03:54,550
No, we need one for the bat and the ghost as well.
47
00:03:54,610 --> 00:03:56,710
Control and see, control and B, control.
48
00:03:56,830 --> 00:04:02,590
The schools say ghost attack and bat attack.
49
00:04:05,780 --> 00:04:16,300
That means that now I can save this, go into my damage and I can say main darts and which ones less
50
00:04:16,310 --> 00:04:20,030
but sohbat attack equals true.
51
00:04:21,600 --> 00:04:29,390
So I know that I've just been attacked by Abbott control and C, control and B, control.
52
00:04:29,660 --> 00:04:37,280
And they say that this one is a ghost attack and this one is a zombie attack.
53
00:04:43,620 --> 00:04:50,730
So now that I know I'm being attacked, what we want to do inside of the update and we do need to do
54
00:04:50,730 --> 00:04:55,770
it in the update, unfortunately, because it could be happening on any frame.
55
00:04:55,950 --> 00:04:58,680
And if it's after one second, it's probably just too late.
56
00:04:59,430 --> 00:05:05,790
So I'm going to leave myself a comment and this is going to be damage visuals.
57
00:05:07,680 --> 00:05:18,960
So I'm going to say, if zombie attack is equal to true, then in that case, we instantly want to switch
58
00:05:18,960 --> 00:05:19,350
it off.
59
00:05:20,250 --> 00:05:25,860
So zombie attack essentials, it only runs on one prank equals false.
60
00:05:26,910 --> 00:05:33,210
And then we need access to images, OK, which I haven't put in yet.
61
00:05:33,870 --> 00:05:40,910
So public health type images, I don't believe that we've done any UI elements yet.
62
00:05:40,920 --> 00:05:52,770
So using unity engine dot UI, that's going to give us access to things like images and buttons and
63
00:05:52,770 --> 00:05:53,640
those kind of things.
64
00:05:54,900 --> 00:06:01,290
Now, I can say public of type, image and core.
65
00:06:05,640 --> 00:06:08,980
Fact, I don't need it to be an image of just it's a game object.
66
00:06:09,220 --> 00:06:10,330
Probably easier that way.
67
00:06:11,260 --> 00:06:15,190
So actually, I can take you I will put it back later.
68
00:06:18,100 --> 00:06:22,950
Public game object I call zombie graphic.
69
00:06:24,260 --> 00:06:24,820
Let's call it.
70
00:06:30,020 --> 00:06:35,090
Uh, so I mean, the updates and I'm going to say zombie graphic.
71
00:06:36,960 --> 00:06:40,400
Don said active to trip.
72
00:06:42,500 --> 00:06:50,900
OK, going to switch that up and then we do have to switch it back off again so we can start a routine
73
00:06:52,220 --> 00:06:54,710
and I will call zombie off.
74
00:06:58,310 --> 00:07:02,840
Now, I do need some time, so I'm going to create a new wait for second soapier.
75
00:07:04,770 --> 00:07:06,040
Wait for seconds.
76
00:07:06,110 --> 00:07:09,260
I'll call it graphic.
77
00:07:10,000 --> 00:07:10,320
Pause.
78
00:07:11,950 --> 00:07:17,470
And then that's going to equal a new wait for seconds.
79
00:07:20,080 --> 00:07:22,600
It's going to equal about zero point three.
80
00:07:23,500 --> 00:07:23,680
All right.
81
00:07:23,710 --> 00:07:24,670
Not very long at all.
82
00:07:26,380 --> 00:07:29,100
So now I can create my zombie off.
83
00:07:29,110 --> 00:07:30,620
I'll go right down to the bottom.
84
00:07:31,060 --> 00:07:31,840
Do it down here.
85
00:07:33,320 --> 00:07:36,730
I enumerator zombie off.
86
00:07:40,890 --> 00:07:43,220
Can't remember if it was capital Z or not.
87
00:07:44,670 --> 00:07:45,470
Soon find out
88
00:07:48,350 --> 00:07:53,930
it's turned yellow, so it must be correct, then it's a yield turn.
89
00:07:55,160 --> 00:07:57,020
And it was professor.
90
00:07:59,910 --> 00:08:00,410
Pause.
91
00:08:00,900 --> 00:08:01,470
There we go.
92
00:08:02,880 --> 00:08:03,480
Excellent.
93
00:08:03,690 --> 00:08:06,780
So now we can simply switch off zombie graphic.
94
00:08:07,980 --> 00:08:15,450
So some epigraphic don't sell out to Fox, switches it off again after zero point three.
95
00:08:18,680 --> 00:08:20,330
OK, so we now update.
96
00:08:21,240 --> 00:08:27,620
Oh, it was a lowercase C, so it just changed up to an uppercase if zombie attack is equal to true.
97
00:08:30,260 --> 00:08:33,020
Let's do the same with other ones.
98
00:08:33,200 --> 00:08:36,530
So control Z, control V, control V.
99
00:08:37,550 --> 00:08:45,590
And I'm going to do if that attack and if ghost attack.
100
00:08:48,670 --> 00:08:50,740
Switch them both off immediately.
101
00:08:57,580 --> 00:08:59,380
And so we can actually.
102
00:09:01,960 --> 00:09:08,680
And if you like, optimize things instead of calling Separate Coroutine, you can actually call the
103
00:09:08,680 --> 00:09:09,880
exact same currency.
104
00:09:10,600 --> 00:09:13,870
But on these ones, we just simply switch off different graphics.
105
00:09:13,900 --> 00:09:16,090
So we've got our zombie graphic.
106
00:09:16,090 --> 00:09:19,630
We now need our public game objects of.
107
00:09:20,080 --> 00:09:28,840
But graphic and public game objects of ghost graphic.
108
00:09:34,220 --> 00:09:42,230
So all we have to do here is take our back graphics, which are done, ghost graphics which are done,
109
00:09:43,700 --> 00:09:48,140
and as soon as we've done that, we will run this same coroutine.
110
00:09:48,710 --> 00:09:57,890
So after zero point three seconds, we simply switch them all control and see saves up and to call numerous
111
00:09:57,890 --> 00:09:58,940
our enumerators.
112
00:09:59,520 --> 00:10:05,330
So then we can say that graphic and ghost graphic.
113
00:10:07,170 --> 00:10:08,040
Switch them all off.
114
00:10:08,370 --> 00:10:08,790
OK.
115
00:10:10,830 --> 00:10:11,250
That's it.
116
00:10:11,730 --> 00:10:18,210
All right, so let's now check if you've got any empty slots we should do.
117
00:10:21,620 --> 00:10:29,960
So we have a zombie graphic, but graphic and ghost graphic.
118
00:10:31,310 --> 00:10:38,240
Let's test this now, so let's play and wait for these characters to actually attack the player.
119
00:10:52,530 --> 00:10:53,460
OK, great.
120
00:10:53,560 --> 00:10:57,360
Yep, so that coming up, I think zero point three should be fine.
121
00:10:57,690 --> 00:11:02,520
Normally you're not going to be getting attacked that fast, and at least not until later levels.
122
00:11:03,300 --> 00:11:04,440
So we'll sort that out later.
123
00:11:05,010 --> 00:11:10,560
What we'll do in the next video is actually get a health bar so you can actually preview our much health
124
00:11:10,710 --> 00:11:11,460
you have left.
10934
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.