1
00:00:03,070 --> 00:00:05,950
In this lecture, we're going to play around a little bit with our Sprite shape.

2
00:00:05,950 --> 00:00:09,850
We're going to make our snow look a little bit better and we're going to add an edge collider so that

3
00:00:09,850 --> 00:00:14,840
we can start to use Unity's physics system to make things roll down hills.

4
00:00:14,860 --> 00:00:16,030
Okay, let's get started.

5
00:00:16,059 --> 00:00:18,550
First thing I'll do here is to move my sprite shape.

6
00:00:18,560 --> 00:00:23,950
So I'm going to click on my Sprite shape at this level, hit W on the keyboard and just move it to the

7
00:00:23,950 --> 00:00:25,060
start of the level.

8
00:00:25,060 --> 00:00:29,710
So you can see here where the camera is, the camera is at the origin 000.

9
00:00:29,710 --> 00:00:35,950
So it makes sense to have my level start at zero zero and I'll just position my world so that it fits

10
00:00:35,950 --> 00:00:39,490
roughly where I want it to be with the camera.

11
00:00:39,520 --> 00:00:40,660
Okay, round about there.

12
00:00:40,660 --> 00:00:41,170
It's good.

13
00:00:41,170 --> 00:00:44,320
Okay, so what we're going to do here is add an edge collider.

14
00:00:44,320 --> 00:00:49,810
So click on your level, sprite shape and scroll on down, find add component and we're going to search

15
00:00:49,810 --> 00:00:54,220
for Edge Collider two DX Click and then bump straight away.

16
00:00:54,220 --> 00:01:01,690
You'll see that has added a collider all the way along our sprite sheet, which for me is Magic Collision

17
00:01:01,690 --> 00:01:02,950
has already been added.

18
00:01:02,950 --> 00:01:07,180
So you can go and modify this, click on the sprite shape, click on edit spline.

19
00:01:07,180 --> 00:01:12,550
I could go and move any of these nodes and the collision flows along as well.

20
00:01:12,550 --> 00:01:17,740
That's such a powerful thing to know when it comes to making platformers or making shapes or making

21
00:01:17,740 --> 00:01:19,060
any sort of product as well.

22
00:01:19,060 --> 00:01:20,200
This is this is huge.

23
00:01:20,200 --> 00:01:20,650
I love it.

24
00:01:20,650 --> 00:01:26,980
Now, what I want to do next is add a ball at a circle that can roll down this particular hill so I

25
00:01:26,980 --> 00:01:28,120
can roll along in our level.

26
00:01:28,120 --> 00:01:32,590
I'm going to give that to you as a quick challenge is to make a ball roll down the hill.

27
00:01:32,590 --> 00:01:35,680
I'm not going to give you any more information, see if you can figure it out from there.

28
00:01:35,680 --> 00:01:36,400
So that is a challenge.

29
00:01:36,400 --> 00:01:37,180
Pause video.

30
00:01:37,180 --> 00:01:37,860
Take that on.

31
00:01:37,870 --> 00:01:38,920
See you back here when you're done.

32
00:01:41,690 --> 00:01:42,170
Okay.

33
00:01:42,170 --> 00:01:47,540
Now, if you jumped over into your hierarchy and right click and created a 2D object, then you're in

34
00:01:47,540 --> 00:01:49,250
the right ballpark for sure.

35
00:01:49,280 --> 00:01:51,130
If you clicked on sprites, excellent.

36
00:01:51,140 --> 00:01:56,900
Now if you went and said sprite circle and then add a rigid body to that, add a collider to that,

37
00:01:56,900 --> 00:01:57,620
that's perfect.

38
00:01:57,620 --> 00:01:59,210
That's a great way of going about doing it.

39
00:01:59,210 --> 00:02:00,980
I'm going to show you something slightly different.

40
00:02:00,980 --> 00:02:05,190
If you look at physics, you'll see that we have what is called a dynamic sprite.

41
00:02:05,210 --> 00:02:11,120
If I create a dynamic sprite, just going to rename it from dynamic sprite to B say ball.

42
00:02:11,120 --> 00:02:13,850
It comes already attached with some cool things.

43
00:02:13,850 --> 00:02:18,320
It already has a circle collider and already has a rigid body 2D.

44
00:02:18,320 --> 00:02:20,150
So we don't need to go and add those things.

45
00:02:20,150 --> 00:02:22,160
It's ready to be a physics thing.

46
00:02:22,160 --> 00:02:27,170
I'm just going to line it up in my scene view so that it matches what I can see in my camera view.

47
00:02:27,170 --> 00:02:29,150
I could move my camera to that spot.

48
00:02:29,150 --> 00:02:32,030
I'm just going to move the ball to the start just here.

49
00:02:32,150 --> 00:02:32,690
Okay.

50
00:02:32,690 --> 00:02:34,790
Now, it's important to make sure that it's dynamic.

51
00:02:34,790 --> 00:02:35,060
Yes.

52
00:02:35,060 --> 00:02:36,110
On the rigid body type.

53
00:02:36,110 --> 00:02:37,010
That's important.

54
00:02:37,010 --> 00:02:39,770
It's also important to make sure that we've got some gravity on.

55
00:02:39,770 --> 00:02:40,700
Yep, that's cool.

56
00:02:40,700 --> 00:02:43,430
So when I click on play, everything else should take care of itself.

57
00:02:43,430 --> 00:02:46,370
The ball just drops to the ground bonk and then roll, roll, roll.

58
00:02:46,370 --> 00:02:51,440
You see, my screen went big just now because I've still got maximize on play clicked on for some reason.

59
00:02:51,440 --> 00:02:55,070
So in my game window I might need to scroll over here, find maximize on play.

60
00:02:55,070 --> 00:02:55,970
I'm going to turn that off.

61
00:02:55,970 --> 00:02:59,930
But obviously if you wanted to have your game take up the full screen, you're going to have a maximize

62
00:02:59,930 --> 00:03:01,040
on play turned on.

63
00:03:01,640 --> 00:03:04,100
I can turn it off for now and then just do that one more time.

64
00:03:04,100 --> 00:03:10,070
Click on play and my ball is going to roll using gravity and using its physics system.

65
00:03:10,070 --> 00:03:12,380
Excellent roll or roll, but you can see there's a problem.

66
00:03:12,380 --> 00:03:17,780
We've got a little bit of a gap between where the ball is and where our world is because our edge collider

67
00:03:17,780 --> 00:03:21,230
is above where our snow wants to be.

68
00:03:21,230 --> 00:03:22,340
How do we address that?

69
00:03:22,340 --> 00:03:27,770
Well, to be honest, it took me ages and ages and ages to track this down when I was wrestling with

70
00:03:27,770 --> 00:03:28,730
why this is the case.

71
00:03:28,730 --> 00:03:30,710
But the fix is incredibly simple.

72
00:03:30,710 --> 00:03:35,480
Click on your level, sprite shape and then under Collider you can see an offset.

73
00:03:35,480 --> 00:03:36,920
We want to change that offset.

74
00:03:36,920 --> 00:03:38,270
I'm going to drag it down.

75
00:03:38,270 --> 00:03:39,440
You can do it wherever you want.

76
00:03:39,440 --> 00:03:43,550
I'm going to drag it down to be just a little bit within the snow roundabout.

77
00:03:43,550 --> 00:03:46,280
For me, it's a 0.31 when I click on play.

78
00:03:46,280 --> 00:03:51,230
Now, the ball should look like it's in the snow, touching it properly, yet rolling along the snow.

79
00:03:51,230 --> 00:03:51,980
That's what we want.

80
00:03:51,980 --> 00:03:57,530
Now, another thing we'll do while we're here is just have a look at the scaling of this amount of snow

81
00:03:57,530 --> 00:03:58,790
versus all of the blue.

82
00:03:58,790 --> 00:04:00,110
I think I want some more snow.

83
00:04:00,110 --> 00:04:04,250
So what I'm saying is I want my tile to be larger.

84
00:04:04,250 --> 00:04:06,440
And the way that we do this is a little bit trickier.

85
00:04:06,440 --> 00:04:11,420
But I'm going to scroll out, scroll out so that I can see all of my level, click on my level, sprite

86
00:04:11,420 --> 00:04:18,290
shape, click on edit spline drag to select all of the dots, all of the points.

87
00:04:18,290 --> 00:04:21,079
And now in here you can see we've got something called height.

88
00:04:21,079 --> 00:04:26,960
And if I increase the height, it will make all of my snow look bigger and or I can drag it the other

89
00:04:26,960 --> 00:04:27,770
way and make it smaller.

90
00:04:27,770 --> 00:04:32,900
So drag it to the point where I think it looks pretty good around about there.

91
00:04:32,900 --> 00:04:37,880
I think, yeah, that's not too bad in relation to ball and snow and blue and all that kind of jazz.

92
00:04:37,880 --> 00:04:43,250
Now when I scroll back in, let's see if it has retained on a double click on my ball to zoom right

93
00:04:43,250 --> 00:04:46,070
into the ball, then I'll click back on my sprite shape again.

94
00:04:46,070 --> 00:04:51,380
Yeah, it's retained the placement for where our collision is relative to the outside of the sprite

95
00:04:51,380 --> 00:04:51,890
shape.

96
00:04:51,890 --> 00:04:56,180
I can move my ball just a little bit above to make sure it's not touching the thing.

97
00:04:56,180 --> 00:04:56,450
Cool.

98
00:04:56,450 --> 00:04:56,960
So there we go.

99
00:04:56,960 --> 00:04:58,790
So I've just made it look a little bit nicer now.

100
00:04:58,790 --> 00:05:04,280
One thing I skipped over quickly because I gave you assets already that were already cut up nicely.

101
00:05:04,280 --> 00:05:09,500
But if you look at this snow tile, you can see in our little preview here, it's got a curve on the

102
00:05:09,500 --> 00:05:14,420
end of it to say, well, we could have this as an end point, but in our world we don't see that curve.

103
00:05:14,420 --> 00:05:18,590
That's because I've already edited it in the Sprite editor, so I want to show you that process.

104
00:05:18,590 --> 00:05:23,420
In case you're using any other particular shape, you click on Sprite editor and you can see in here

105
00:05:23,420 --> 00:05:24,740
we've got these green lines.

106
00:05:24,740 --> 00:05:31,160
So I've already said for this one graphic I'm using, I want the shape that we're using for our particular

107
00:05:31,160 --> 00:05:34,400
Sprite shape is to go from here down to here.

108
00:05:34,400 --> 00:05:36,200
Hopefully you can see those green lines in there.

109
00:05:36,230 --> 00:05:40,820
If I was to move that, I could say, well, maybe I want it to go from there all the way to there and

110
00:05:40,820 --> 00:05:42,590
then click on Apply.

111
00:05:42,800 --> 00:05:48,440
And now when we go back into our into our scene, you can see that the curves have been captured and

112
00:05:48,440 --> 00:05:51,320
it doesn't tile in a very nice way at all, does it?

113
00:05:51,320 --> 00:05:53,420
So that's an important thing for us to note.

114
00:05:53,420 --> 00:05:57,920
I'm going to go back into my Sprite editor's click on my Snow Tile Sprite editor and then I'm just going

115
00:05:57,920 --> 00:06:03,170
to put this just a little bit past where the curve is, just there a little bit past where the curve

116
00:06:03,170 --> 00:06:04,070
is just here.

117
00:06:04,070 --> 00:06:06,140
So we could have done this when we're placing it down.

118
00:06:06,140 --> 00:06:07,970
But I just wanted to point that out.

119
00:06:07,970 --> 00:06:12,290
Now that we need to do that, if you've got anything else you're bringing in, the other thing you might

120
00:06:12,290 --> 00:06:18,110
be wrestling with is if your fill isn't texturing properly, particularly if you've brought in your

121
00:06:18,110 --> 00:06:19,310
own asset for this as well.

122
00:06:19,310 --> 00:06:22,100
And I totally encourage you to use different assets to what I'm using.

123
00:06:22,100 --> 00:06:28,160
So if you click on the Blue Fill need to make sure that where it says the wrap mode we have wrap mode

124
00:06:28,160 --> 00:06:28,850
is repeat.

125
00:06:28,850 --> 00:06:35,720
If you have wrap motors clamp, it might give you some weird looking artifacts, particularly if your

126
00:06:35,720 --> 00:06:38,150
fill isn't just one color minus just one color.

127
00:06:38,150 --> 00:06:40,160
So it can't really go wrong no matter how.

128
00:06:40,490 --> 00:06:41,870
Raps or how it repeats.

129
00:06:41,870 --> 00:06:48,740
But here in rap mode, I've got repeat and it's the same if I click on my sprite tile for the snow in

130
00:06:48,740 --> 00:06:49,940
here we have repeat as well.

131
00:06:49,940 --> 00:06:51,500
So just want to point those things out.

132
00:06:51,500 --> 00:06:55,460
I really encourage you to go add your own assets to this so it looks different.

133
00:06:55,460 --> 00:07:00,500
And in this lecture we've gone and added an edge collider so that we can get that whole physics dynamic

134
00:07:00,500 --> 00:07:05,690
and use our sprite shape as our world that our snowboarder is going to be cruising around on.

135
00:07:05,690 --> 00:07:06,800
So good stuff.

136
00:07:06,800 --> 00:07:07,940
I'll see you in the next lecture.

