1
00:00:00,710 --> 00:00:05,520
Welcome back, my fellow game developers in this video,

2
00:00:05,520 --> 00:00:09,750
when we run the game are just does not just opened up.

3
00:00:09,750 --> 00:00:12,720
It opens up and gives us in random mapping.

4
00:00:12,720 --> 00:00:14,690
We'll pick it up and we start shooting.

5
00:00:14,685 --> 00:00:18,405
And the best part is that if we keep pressing the Iike,

6
00:00:18,405 --> 00:00:20,135
we don't have more weapons.

7
00:00:20,130 --> 00:00:23,060
You will see why this is such an amazing thing to do.

8
00:00:23,055 --> 00:00:25,025
And a couple of minutes,

9
00:00:25,020 --> 00:00:27,390
so let's not waste any more time.

10
00:00:27,390 --> 00:00:29,910
And let's get started.

11
00:00:29,910 --> 00:00:31,200
K.

12
00:00:31,200 --> 00:00:34,020
So now we have our chest opening.

13
00:00:34,020 --> 00:00:37,050
We actually want to spawn some kind of weapon.

14
00:00:37,050 --> 00:00:38,810
So what we'll do is we're going to

15
00:00:38,805 --> 00:00:42,285
instantiate one of the potential weapons.

16
00:00:42,280 --> 00:00:45,920
Where is it on the weapons just right here.

17
00:00:45,920 --> 00:00:48,110
Now, there is one more thing

18
00:00:48,110 --> 00:00:49,880
that we need to take into consideration,

19
00:00:49,880 --> 00:00:53,060
and that is when we spawn one of these pickups.

20
00:00:53,060 --> 00:00:56,930
It's on the chest immediately and the chest is solid.

21
00:00:56,930 --> 00:00:58,610
So what we're going to do is we're

22
00:00:58,610 --> 00:01:00,370
going to create a spam,

23
00:01:00,365 --> 00:01:04,355
spam, spam spawn point in here.

24
00:01:04,355 --> 00:01:08,125
And we're calling spawn point.

25
00:01:08,120 --> 00:01:10,250
And we'll just move it a little bit down.

26
00:01:10,250 --> 00:01:12,760
And this is where I can just make this bigger.

27
00:01:12,755 --> 00:01:15,355
And this is where the gun is going to

28
00:01:15,350 --> 00:01:18,430
spawn for us and we'll just put it about here.

29
00:01:18,425 --> 00:01:20,785
And if you want, you can also add to each of

30
00:01:20,780 --> 00:01:24,220
these guns the pickup, the D layer.

31
00:01:24,215 --> 00:01:26,125
I think it's a good idea because if

32
00:01:26,120 --> 00:01:28,550
the player is standing right in front of the chest,

33
00:01:28,550 --> 00:01:30,800
we won't even see what the gun was.

34
00:01:30,800 --> 00:01:32,990
So it's a good idea. It's pretty easy.

35
00:01:32,990 --> 00:01:34,190
Just add the script.

36
00:01:34,190 --> 00:01:35,830
We'll maybe do it later on.

37
00:01:35,825 --> 00:01:38,575
But for now, let's keep focused on what we have.

38
00:01:38,570 --> 00:01:42,760
We're go into the weapons just and in here we'll create

39
00:01:42,755 --> 00:01:47,995
an extra serialized field which is of type transform,

40
00:01:47,990 --> 00:01:52,040
and it's going to be the spawn point.

41
00:01:52,040 --> 00:01:54,280
Save that back in Unity,

42
00:01:54,275 --> 00:01:59,245
wait for it to compile and weapons just there we go.

43
00:01:59,240 --> 00:02:03,080
The spot point that now what we're going to

44
00:02:03,080 --> 00:02:08,300
do is in here we want to create a random number,

45
00:02:08,300 --> 00:02:10,160
or at least when we actually press

46
00:02:10,160 --> 00:02:12,050
the key will create a random number.

47
00:02:12,050 --> 00:02:13,790
And from that random number we will

48
00:02:13,790 --> 00:02:16,130
instantiate one of the potential gametes.

49
00:02:16,130 --> 00:02:19,550
So I'm going to issue it to you as a challenge,

50
00:02:19,550 --> 00:02:22,910
so you'll need to spend the weapons pick up.

51
00:02:22,910 --> 00:02:23,630
In here.

52
00:02:23,630 --> 00:02:24,770
We should have pickup.

53
00:02:24,770 --> 00:02:27,470
So you'll need to create a random number.

54
00:02:27,470 --> 00:02:30,980
You'll need to instantiate one of the potential guns.

55
00:02:30,980 --> 00:02:33,320
And you'll need to make sure that it's on

56
00:02:33,320 --> 00:02:36,290
the position of the spawn point.

57
00:02:36,290 --> 00:02:37,700
So with that said,

58
00:02:37,700 --> 00:02:42,470
pause the video right now and go do the challenge.

59
00:02:42,470 --> 00:02:44,540
Okay, welcome back.

60
00:02:44,540 --> 00:02:46,790
So after we change the sprite,

61
00:02:46,790 --> 00:02:48,760
we are going to create an int,

62
00:02:48,755 --> 00:02:56,735
a random weapon, weapon number,

63
00:02:56,735 --> 00:03:01,105
and it's equal to random range.

64
00:03:01,100 --> 00:03:06,290
And the range is from 0 to the potential,

65
00:03:06,290 --> 00:03:10,490
potential weapons dot length.

66
00:03:10,490 --> 00:03:14,510
And in here we are going to go ahead and instantiate.

67
00:03:14,510 --> 00:03:18,410
Instantiate opens up what is the object?

68
00:03:18,410 --> 00:03:24,410
It's going to be the potential weapons on the position,

69
00:03:24,410 --> 00:03:26,450
random weapon number,

70
00:03:26,450 --> 00:03:34,420
the spam point dot position and the spam point 0, 0, 1.

71
00:03:34,415 --> 00:03:35,695
Save that.

72
00:03:35,690 --> 00:03:38,080
And now let's go back and to our game.

73
00:03:38,075 --> 00:03:40,285
I believe this is all that we need to do.

74
00:03:40,280 --> 00:03:42,790
Okay, Let's go back.

75
00:03:42,785 --> 00:03:46,135
Let's make this a bit bigger.

76
00:03:46,130 --> 00:03:47,350
Run the game.

77
00:03:47,345 --> 00:03:49,925
Stand next to the chest, hit the Iike.

78
00:03:49,925 --> 00:03:52,055
There we go. How cool is that?

79
00:03:52,055 --> 00:03:53,245
Now we have the shotgun,

80
00:03:53,240 --> 00:03:55,450
we can actually pick it up and start shooting.

81
00:03:55,445 --> 00:03:57,205
Now, there is one more thing

82
00:03:57,200 --> 00:03:59,210
that we need to take into consideration.

83
00:03:59,210 --> 00:04:01,660
And then I can spawn as money,

84
00:04:01,655 --> 00:04:03,295
weapons as I want,

85
00:04:03,290 --> 00:04:06,910
is something that you might think is good.

86
00:04:06,905 --> 00:04:08,915
But in actuality, it's not.

87
00:04:08,915 --> 00:04:11,365
Maybe you do want to have this, maybe you don't.

88
00:04:11,360 --> 00:04:13,570
And I'm going to give you

89
00:04:13,565 --> 00:04:16,375
an opportunity to do this on your own.

90
00:04:16,370 --> 00:04:17,840
Pause the video if you want.

91
00:04:17,840 --> 00:04:19,450
This is not an official challenge.

92
00:04:19,445 --> 00:04:20,635
I'll give you a couple of seconds.

93
00:04:20,630 --> 00:04:24,480
Pause the video, figure out how we can stop this.

94
00:04:24,820 --> 00:04:27,230
O K time's up.

95
00:04:27,230 --> 00:04:29,350
So in here I'm going to add a,

96
00:04:29,350 --> 00:04:35,780
another Boolean which is the has been open.

97
00:04:35,780 --> 00:04:39,580
It opened, opened. And in here,

98
00:04:39,575 --> 00:04:41,335
after we actually open the chest,

99
00:04:41,330 --> 00:04:45,180
the has been opened equals true.

100
00:04:45,340 --> 00:04:49,180
And another condition in here,

101
00:04:49,175 --> 00:04:53,585
if it has not been opened,

102
00:04:53,585 --> 00:04:56,855
save that, and I want to add it to one other place.

103
00:04:56,855 --> 00:05:01,625
And it's in here where we set the Vicky back to true.

104
00:05:01,625 --> 00:05:04,535
So in here I'm going to say,

105
00:05:04,535 --> 00:05:06,835
excuse me, that's a lot.

106
00:05:06,830 --> 00:05:10,700
If it has not been opened,

107
00:05:10,700 --> 00:05:14,740
then we are going to turn this on.

108
00:05:14,735 --> 00:05:16,705
Save that.

109
00:05:16,700 --> 00:05:18,080
And if we're out,

110
00:05:18,080 --> 00:05:19,550
then we'll just set it to false and

111
00:05:19,550 --> 00:05:21,020
will never open an account.

112
00:05:21,020 --> 00:05:22,850
So we don't want to keep seeing the text

113
00:05:22,850 --> 00:05:24,970
when we have already opened that chest.

114
00:05:24,965 --> 00:05:27,315
So we run the game.

115
00:05:27,315 --> 00:05:30,525
We have the chest.

116
00:05:30,520 --> 00:05:32,140
We open it up.

117
00:05:32,140 --> 00:05:34,870
We have the shotgun who tried to open up another time.

118
00:05:34,870 --> 00:05:37,480
No, we cannot if we go back, that's it.

119
00:05:37,480 --> 00:05:39,520
We don't see it because we've already opened

120
00:05:39,520 --> 00:05:41,850
and we pick up our app and we shoot around.

121
00:05:41,845 --> 00:05:44,965
We have an amazing weapons spawning,

122
00:05:44,965 --> 00:05:47,115
chest opening, picking up

123
00:05:47,110 --> 00:05:49,900
mechanic that works perfectly fine.

124
00:05:49,900 --> 00:05:51,540
So I hope you enjoy it.

125
00:05:51,535 --> 00:05:54,795
And if you want to have some extra challenge on the side,

126
00:05:54,790 --> 00:05:57,970
maybe create some kind of animation for the chest where

127
00:05:57,970 --> 00:06:02,470
it may be wobbles left and right before it opens up.

128
00:06:02,470 --> 00:06:05,170
Or I don't know, maybe add some kind of

129
00:06:05,170 --> 00:06:06,940
extra animation if you have

130
00:06:06,940 --> 00:06:09,330
for the chest to find on yourself.

131
00:06:09,325 --> 00:06:12,055
With that done, make sure to always commit

132
00:06:12,050 --> 00:06:15,410
your changes if you haven't already, you know the drill.

133
00:06:15,410 --> 00:06:17,180
I it helps me out a

134
00:06:17,180 --> 00:06:19,610
lot when you leave a review positive 1,

135
00:06:19,610 --> 00:06:24,590
of course, a review on the course Atlas, the platform.

136
00:06:24,590 --> 00:06:26,720
Know that I am the author of

137
00:06:26,720 --> 00:06:29,710
this course is worth watching,

138
00:06:29,705 --> 00:06:31,565
worth showing to other people

139
00:06:31,565 --> 00:06:33,775
and joined the discord obviously,

140
00:06:33,770 --> 00:06:34,820
if you haven't already,

141
00:06:34,820 --> 00:06:36,910
and I hope you enjoyed this section.

142
00:06:36,905 --> 00:06:38,845
It was really nice. We learned a lot.

143
00:06:38,840 --> 00:06:41,360
And the next one, I'm not sure what we're going to do,

144
00:06:41,360 --> 00:06:44,080
but I'm sure we will figure it out by them.

145
00:06:44,075 --> 00:06:46,585
So let's not waste any more time and

146
00:06:46,580 --> 00:06:50,160
let's go to the next section.

