1
00:00:00,210 --> 00:00:05,820
Hey, and welcome back in this lesson, we're going to be restricting the power position of our ship

2
00:00:05,820 --> 00:00:11,340
that we're moving so we don't want it to be able to move off screen and when it hit start that we get

3
00:00:11,340 --> 00:00:13,410
the activation of being able to move it.

4
00:00:13,560 --> 00:00:16,460
And you can see that it moves outside of the container area.

5
00:00:16,620 --> 00:00:21,240
So we want to stop the movement for off of the container area and we want to restrict it within those

6
00:00:21,240 --> 00:00:27,300
boundaries so we can do that within the condition where we're checking to see if left is pressed and

7
00:00:27,300 --> 00:00:38,730
also checking to see if the value of the left position so that the temp position is greater than zero.

8
00:00:39,120 --> 00:00:41,550
And if it is, then we're OK to subtract.

9
00:00:41,580 --> 00:00:42,390
So let's try that.

10
00:00:42,750 --> 00:00:49,410
And now whenever we move, so we're getting a value of greater than zero, but this is the main offset

11
00:00:49,410 --> 00:00:49,860
value.

12
00:00:50,070 --> 00:00:52,860
So we want to make sure that it's related to the container.

13
00:00:53,190 --> 00:00:59,250
So checking again, that container dim and we do have a left position for that container.

14
00:00:59,820 --> 00:01:00,990
So now let's try that.

15
00:01:01,140 --> 00:01:08,040
And you can see when hits start game that now we're restricted to the left position and we can also

16
00:01:08,040 --> 00:01:13,710
do the same thing for right where we're checking to see if the position.

17
00:01:13,890 --> 00:01:21,240
So temp position is less than a container right position.

18
00:01:21,780 --> 00:01:23,070
So it's in that container.

19
00:01:23,070 --> 00:01:24,780
We had a number of options.

20
00:01:25,080 --> 00:01:30,480
We could also do with and I'll show you what happened here is that we're actually moving off of the

21
00:01:30,480 --> 00:01:34,530
screen, and that's because we're restricted to the right position.

22
00:01:34,650 --> 00:01:42,330
But the right position is here and the right the left position of this object is over here.

23
00:01:42,570 --> 00:01:47,730
So we need to add to the position the width of that current ship.

24
00:01:48,030 --> 00:01:50,700
So adding that in and the way that we can do that.

25
00:01:50,710 --> 00:01:57,240
So just as we did the offset left, we can do offset and there's an option here for offset width.

26
00:01:57,720 --> 00:02:03,950
So now if we calculate that, that's going to give us the right side of our ship.

27
00:02:04,350 --> 00:02:05,350
So moving that in.

28
00:02:05,350 --> 00:02:10,460
Now you can see that we're restricted within the container boundaries and we can't go outside.

29
00:02:10,860 --> 00:02:13,590
So go ahead and add those conditions into your project.

30
00:02:13,870 --> 00:02:19,830
So this gives you the ability to restrict where the player can move with their with their ship.
