Step 3

Detecting the Player's tag

The finish line figures can figure out where the player is by detecting the tag on it. (Remember, we discussed using tags in this tutorial: Dangerous obstacles: Collisions and physics.)

We'll use the tag "player" on our player character, so while you still have the script for the finish line object open, change the tag in "first instance by tag" to "player".

Now we need to make sure our player character actually has that tag. Close this script by clicking Level Editor, and make sure you save the script with a name like "Finish Line".

Edit the script on the player character, grab the "add tag tag name on myself" block (from Sensing), and drag this block into the bottom of the "When created" stack of blocks.

Change "tag name" to "player".

Click Play to test your game. What happens when you get to the finish line? Make sure you start building the next level so your character actually has somewhere to go!

results matching ""

    No results matching ""