﻿1
00:00:04,340 --> 00:00:05,360
‫Hello and welcome.

2
00:00:05,360 --> 00:00:11,570
‫In this lecture, we're going to be seeing how we can add a tag to our gargoyle actor that makes it

3
00:00:11,570 --> 00:00:15,560
‫be the only actor acceptable to our secret door.

4
00:00:15,590 --> 00:00:19,760
‫Let's dive in and see how this actor tagging system works.

5
00:00:20,580 --> 00:00:20,940
‫Now.

6
00:00:20,940 --> 00:00:27,090
‫We don't want our trigger to be responding to every single case where we get an overlap.

7
00:00:27,090 --> 00:00:32,710
‫No, we want it to be responding very specifically only to one actor, the gargoyle.

8
00:00:32,730 --> 00:00:39,210
‫So how do we go about configuring this trigger so that the gargoyle is the only thing it responds to?

9
00:00:39,480 --> 00:00:48,630
‫Well, fortunately, there is a mechanism for tagging certain actors with certain strings to say that

10
00:00:48,630 --> 00:00:50,040
‫it has a specific property.

11
00:00:50,040 --> 00:00:57,050
‫So if you go and select the Gargoyle actor and scroll down in the details pane, you're going to find

12
00:00:57,060 --> 00:00:59,000
‫and in fact, you can probably just search for it.

13
00:00:59,010 --> 00:01:00,480
‫You can search for tags.

14
00:01:00,480 --> 00:01:04,470
‫In particular, we're looking not for component tags, but actor tags.

15
00:01:04,560 --> 00:01:06,690
‫You can see that there is an array element.

16
00:01:06,720 --> 00:01:08,580
‫Now we understand what arrays are.

17
00:01:08,880 --> 00:01:10,380
‫So you can have multiple tags.

18
00:01:10,380 --> 00:01:11,940
‫It's an array of strings.

19
00:01:11,940 --> 00:01:17,130
‫So the first thing in this array is you can add it with the add button.

20
00:01:17,130 --> 00:01:21,510
‫You can delete elements from it with the delete button, and then you can add in a string.

21
00:01:21,510 --> 00:01:28,050
‫So for example, we might want to put in a string that says it's going to unlock door one.

22
00:01:28,050 --> 00:01:33,570
‫So we'll put in a string that says unlock one, for example.

23
00:01:33,930 --> 00:01:41,010
‫And then what we want to do is check whether that string matches unlock one over in our trigger component

24
00:01:41,010 --> 00:01:41,880
‫CP.

25
00:01:41,910 --> 00:01:48,330
‫So what we can do here is we can query the actor when we're going over the overlapping actors in our

26
00:01:48,330 --> 00:01:52,580
‫for loop and we can check whether it has a particular actor tag.

27
00:01:52,590 --> 00:01:53,750
‫It's very easy to do.

28
00:01:53,760 --> 00:01:54,990
‫There is a function for it.

29
00:01:54,990 --> 00:01:55,480
‫So we do.

30
00:01:55,500 --> 00:02:04,470
‫Actor, Arrow, actor has tag and then you just have to pass in the name, the f name of the tag, which

31
00:02:04,470 --> 00:02:07,470
‫you can actually just use a string to put this in.

32
00:02:07,470 --> 00:02:14,730
‫So what we can do is we can put in unlock one like so and we can put a semicolon at the end of the line

33
00:02:14,730 --> 00:02:17,820
‫and we can wrap this in an if statement.

34
00:02:17,820 --> 00:02:26,610
‫So saying if the actor has tag unlock one, then let's print out a log message which is going to basically

35
00:02:26,610 --> 00:02:33,690
‫be that log message saying that we're overlapping, we can say actually unlocking instead so that it's

36
00:02:33,690 --> 00:02:35,130
‫clear that there's a difference.

37
00:02:35,130 --> 00:02:40,590
‫And otherwise, if it doesn't find anything to unlock it, it's not going to print anything out.

38
00:02:40,590 --> 00:02:47,040
‫And let's remove the use of actor name so that all the log message says is that we are unlocking now

39
00:02:47,040 --> 00:02:48,090
‫let's recompile.

40
00:02:48,090 --> 00:02:52,530
‫And once that's done, let's open up our output log and dock it to the layout so that we can see the

41
00:02:52,530 --> 00:02:53,550
‫results.

42
00:02:53,580 --> 00:02:56,640
‫Let's go and start near our gargoyle.

43
00:02:56,640 --> 00:02:59,790
‫Hit play, pick up the gargoyle, take it to the alcove.

44
00:02:59,790 --> 00:03:04,260
‫I just want to show you that if I step in, there is no log message.

45
00:03:04,260 --> 00:03:07,740
‫There's a log message coming from the beep player.

46
00:03:07,740 --> 00:03:12,660
‫We could remove that log, but there's nothing coming from our trigger.

47
00:03:12,690 --> 00:03:15,960
‫Now let's take the gargoyle and stick it in the alcove.

48
00:03:16,850 --> 00:03:22,630
‫And they go it can see that it is unlocking because of the tag that we have applied.

49
00:03:22,640 --> 00:03:26,990
‫So let's challenge you to make the tag that we've got there configurable at the moment.

50
00:03:26,990 --> 00:03:29,570
‫We've just hardcoded it into our code.

51
00:03:29,570 --> 00:03:32,900
‫So you're going to create a new editable you property.

52
00:03:32,900 --> 00:03:38,780
‫That type should be an F name so that it matches what the actor tag is expecting.

53
00:03:38,900 --> 00:03:45,290
‫And you're going to replace your fixed string with this in the code and configure it in the level instead,

54
00:03:45,290 --> 00:03:50,660
‫which is the right place so that we can reuse this trigger in multiple places.

55
00:03:50,690 --> 00:03:52,250
‫Pause a video and have a go.

56
00:03:55,210 --> 00:03:55,490
‫Okay.

57
00:03:55,510 --> 00:03:56,360
‫Welcome back.

58
00:03:56,380 --> 00:04:00,760
‫So we're going to go over to the header file for our trigger components.

59
00:04:00,760 --> 00:04:11,890
‫We're going to go in to the bottom and create a new private section and put a new property edit anywhere.

60
00:04:12,580 --> 00:04:17,920
‫And it's going to be a type F name, not a pointer to an F name and actual F name, which we're going

61
00:04:17,920 --> 00:04:21,790
‫to call the I didn't tell you what to call it, but hopefully you try to think up a good name.

62
00:04:21,790 --> 00:04:30,880
‫I'm going to call this the acceptable actor tag, give it no default at the moment and go over into

63
00:04:30,880 --> 00:04:32,200
‫our trigger component, CBP.

64
00:04:32,200 --> 00:04:37,240
‫And instead of using unlocking in here as the actor tag we're checking for, we're going to check for

65
00:04:37,240 --> 00:04:39,430
‫the acceptable actor tag.

66
00:04:39,520 --> 00:04:41,350
‫I'm going to go ahead and compile this.

67
00:04:41,350 --> 00:04:45,550
‫Then I'm going to go and find our secret door.

68
00:04:45,550 --> 00:04:49,150
‫I'm going to go and find the trigger components.

69
00:04:49,180 --> 00:04:51,670
‫And you can see that I'm still got the search for TAG.

70
00:04:51,670 --> 00:04:58,810
‫So acceptable act tag shows up straightaway and we're going to put unlock one to make sure it matches

71
00:04:58,810 --> 00:04:59,380
‫the gargoyle.

72
00:04:59,380 --> 00:04:59,860
‫Exactly.

73
00:04:59,860 --> 00:05:04,210
‫The string has to match perfectly and that should have exactly the same result.

74
00:05:04,210 --> 00:05:08,530
‫Do go ahead and test it for yourself, but I'm not going to in the video.

75
00:05:09,220 --> 00:05:09,610
‫Great stuff.

76
00:05:09,610 --> 00:05:16,150
‫So now we've seen how we can tag actors with strings to give them certain game play meanings and do

77
00:05:16,150 --> 00:05:19,990
‫that reasonably configurable and flexibly from within.

78
00:05:19,990 --> 00:05:20,920
‫The editor.

79
00:05:20,950 --> 00:05:22,600
‫I'll see you in the next video.

