What if we want three flags in unique positions, before showing the trophy?
Let’s duplicate to create three flags, flag stands, and triggers. Coloring each pair red, green, and blue. Then change the tags on the respective flags and triggers to be redflag, greenflag, and blueflag.
Please note, that if you want interchangeable positions, leave the tag on all of them as Flag.
PREREQUISITE READING
WHEN TRIGGER IS ENTERED BY OBJECT precedes this tutorial
Duplicate our FlagTrigger script, name it Trophy and set it aside for now. On the FlagTrigger script, let’s adjust our script by deleting When World is Started, and the Show Trophy codeblock.
At the bottom of our events tab, grab Send Event to Object, this is going to allow us to tell the trophy that a flag has been captured. Replace Self with the Trophy object variable. Click on MyEvent and select Custom Event, let’s call this event Objective.
Now open the Trophy script we created earlier. Bring over the When Event is Received codeblock, and change it to match the one we sent from the trigger, Objective. Now that we are receiving the event, let’s go to our variables tab, delete Trophy, and create a new variable called Counter, which is a number that starts at zero.
From our Values tab, grab SetTo, and put Counter on the left side, then get a plus symbol from the Operators tab for the right side. In the “A” slot, put Counter. In the “B” slot we will get a number input from the Values tab, and set it to one. Now every time a flag enters the trigger we increase the Counter by one.
The last thing we need to do is place an If control below the SetTo codeblock. Grab an equals symbol from the Operators tab. On the left side we will place Counter. And on the right, we will place another number input, which we will set to three. Then bring the Show Trophy codeblock down and indent it into the If. Notice the white line showing where it will be placed. We can now delete the When Trigger is Entered by Object event. And the last thing to do is, replace Trophy with Self from the Values tab.
Let’s attach the Trophy script to our trophy, this will replace the NameOnGrab script. Great work!