﻿1
00:00:04,500 --> 00:00:05,670
‫Hello and welcome.

2
00:00:05,670 --> 00:00:12,690
‫In this lecture, we're going to be looking at how we can get the rotation of our camera and apply that

3
00:00:12,690 --> 00:00:14,310
‫to the spawned projectiles.

4
00:00:14,310 --> 00:00:20,700
‫So as I rotate my camera around, you can see the projectiles are being rotated in the same direction.

5
00:00:21,330 --> 00:00:28,290
‫So you'll notice that there is a rotation that we can put in to our projectile.

6
00:00:28,470 --> 00:00:36,210
‫Now, this may be the start of helping us rotate the direction of travel of that projectile.

7
00:00:36,210 --> 00:00:42,390
‫We can use the we can use some information from the projectile later on to actually set our impulse

8
00:00:42,390 --> 00:00:43,590
‫in the correct direction.

9
00:00:44,220 --> 00:00:50,730
‫However, it's currently really hard to tell which way our projectile is rotated because it's entirely

10
00:00:50,730 --> 00:00:51,540
‫spherical.

11
00:00:51,540 --> 00:01:00,090
‫So let's open up the BP projectile class and go to our static measure component and go up right to the

12
00:01:00,090 --> 00:01:03,870
‫top where it has the transform scale property.

13
00:01:03,870 --> 00:01:08,910
‫And let's just increase the scale along the X direction.

14
00:01:08,940 --> 00:01:11,310
‫A value of about two should do the trick.

15
00:01:11,310 --> 00:01:15,540
‫You can see that it becomes this kind of deformed sphere instead.

16
00:01:15,540 --> 00:01:20,970
‫And if we go ahead and play and shoot this sphere, you can see that the direction that it's traveling

17
00:01:20,970 --> 00:01:26,310
‫in is pretty much the, you know, that's that's the direction of the sphere.

18
00:01:26,580 --> 00:01:31,440
‫And so we can see whether our rotation is having any effect when we spawn it.

19
00:01:31,440 --> 00:01:34,770
‫So let's go over to the level blueprint.

20
00:01:34,770 --> 00:01:39,840
‫And the most logical thing to do would be to say, okay, let's go ahead and get the rotation of the

21
00:01:39,840 --> 00:01:40,470
‫player pawn.

22
00:01:40,470 --> 00:01:48,480
‫So let's drag off the player pawn reference node that comes out of get play a pawn and let's look for

23
00:01:48,480 --> 00:01:49,590
‫rotation.

24
00:01:49,920 --> 00:01:57,120
‫And sure enough we can use get active rotation that seems to match with get active location, it returns

25
00:01:57,120 --> 00:01:57,810
‫a rotator.

26
00:01:57,810 --> 00:02:05,010
‫So this seems to fit and we can drag that in to our spawn transform rotation pin of this born actor

27
00:02:05,010 --> 00:02:05,580
‫node.

28
00:02:05,640 --> 00:02:11,400
‫But if we go ahead and play this and we shoot off in different directions, you will actually notice

29
00:02:11,400 --> 00:02:14,790
‫that basically the projectile is not rotating at all.

30
00:02:15,120 --> 00:02:23,880
‫Now, the reason for this is that if we go in and hit play and then instantly eject, so using F eight

31
00:02:24,630 --> 00:02:30,930
‫and have a look at our pawn, we can have a look at the pawns rotation in the details pane so we can

32
00:02:30,930 --> 00:02:35,580
‫click on the pawn, go to the details pane, have a look at the Transform Rotation property and you

33
00:02:35,580 --> 00:02:42,270
‫can see that it's rotated 180 degrees about the Z axis, but that's the only rotation we've got there.

34
00:02:42,720 --> 00:02:49,230
‫So what happens if I repossess the pawn, which I can do from the toolbar right at the top there is

35
00:02:49,230 --> 00:02:53,520
‫a little controller button or I can hit F eight to jump back into the pawn shoes.

36
00:02:53,520 --> 00:02:56,520
‫What happens if I rotate 180 degrees round?

37
00:02:56,520 --> 00:03:00,150
‫I would expect my rotation to reflect that.

38
00:03:00,150 --> 00:03:01,710
‫So I hit F8 again.

39
00:03:01,950 --> 00:03:08,340
‫I jump out and select the default pawn and I have a look at its details pane, but you can see it's

40
00:03:08,340 --> 00:03:15,630
‫rotation hasn't updated and that's because by default the this default pawn in unreal isn't configured

41
00:03:15,630 --> 00:03:18,660
‫to rotate with the camera rotation.

42
00:03:18,660 --> 00:03:20,400
‫Those are two separate things.

43
00:03:20,400 --> 00:03:23,190
‫For whatever reason, it doesn't particularly matter.

44
00:03:23,460 --> 00:03:30,510
‫But what is important is that there is something that does reflect that rotation and that is called

45
00:03:30,510 --> 00:03:32,430
‫the control rotation.

46
00:03:32,430 --> 00:03:39,460
‫So you can drag off of the get player pawn node and you can search for control rotation instead.

47
00:03:39,460 --> 00:03:42,780
‫And you can see there is a get control rotation node.

48
00:03:42,960 --> 00:03:49,140
‫So I'd like to challenge you to try that node out, try the control rotation, replace the get active

49
00:03:49,140 --> 00:03:54,240
‫rotation node and plug in to the spawn node and see whether it has any effect.

50
00:03:54,480 --> 00:03:59,220
‫When you play in the game, do those projectiles point in a different direction?

51
00:03:59,220 --> 00:04:00,720
‫Pause a video and have it go?

52
00:04:04,070 --> 00:04:04,760
‫Okay.

53
00:04:04,760 --> 00:04:05,700
‫Welcome back.

54
00:04:05,720 --> 00:04:13,820
‫So let's delete our get active rotation, pull off of the get player -- node and search for get control

55
00:04:13,820 --> 00:04:16,520
‫rotation and bring that node in.

56
00:04:16,520 --> 00:04:18,980
‫And you can see the output is again a rotator.

57
00:04:18,980 --> 00:04:21,620
‫Hopefully this time the value will be correct, however.

58
00:04:21,620 --> 00:04:26,180
‫So let's get that rotator and connect it up to our input for the spawn actor.

59
00:04:26,240 --> 00:04:32,870
‫We can go ahead and hit play and now if I change the way I'm looking, you can see that these projectiles

60
00:04:32,870 --> 00:04:35,750
‫are flying off a little bit sideways now.

61
00:04:35,750 --> 00:04:41,720
‫They're not traveling in the direction of their rotation that we're going to sort out in the upcoming

62
00:04:41,720 --> 00:04:42,350
‫lectures.

63
00:04:42,350 --> 00:04:44,180
‫But this is a first step.

64
00:04:44,180 --> 00:04:47,780
‫We now know what that direction should be.

65
00:04:47,780 --> 00:04:49,400
‫I'll see you in the next lecture.

