Building A Bridge


A lot of people seem to be confused on how to create bridges that Link can walk underneath, but also travel on top of.  This sounded a bit hard but once I figured it out, I adjusted my tileset just a bit to make it work.  Please be sure to update the data file by downloading it here.  There are actually two different methods for building a bridge: a quick way allows you to do so with absolutely no scripting knowledge, but will limit your hero from being able to do anything more than simply walk between layers, and a more advanced method that will not restrict the hero from acting upon switching between layers.  First I'll show you the script-free method.

 

The Script-free Method

 

Here's what you'll need (per ladder):

This tutorial will show you how to create a bridge you can pass over and under using a ladder for access.

Remember that in the real world, we see bridges as a singular object that connects two higher areas together to make traveling between them easier.  In Solarus, a bridge is two things: it is an object that allows Link to pass through on one layer, and a passage with walls on another.  This might sound contradictory, but don't think of bridges as bridges.  If that's confusing, don't worry I don't blame you.  It will hopefully make sense once we complete this tutorial.

Setting Up the Terrain
First, let's create a couple rock formations.  Nothing too fancy, make a simple shape and then copy and paste it on the opposite side, making sure to place appropriate shadow tiles between the rocks.

You should now have something that looks similar to the image on the left.


Your ladders (on each rock formation) should look like this.  To make it clear, look closely at the image to the left.  The ladder walls overlap.  This is important!!  The overlap will prevent Link from walking off of the ladder and getting trapped in the wall between layers.  Below is the same ladder, split apart to show you how it should look when put together:

As you can see, the ladder itself, and two of its walls are on Layer 0, and the other two walls are on Layer 1.  Make sure that you overlap the ladder walls by two tiles, as seem in the above image!


Begin building your bridge now.  Make sure that all the bridge tiles are one layer above the rock formation tiles.  This is VERY important.

Once the bridge has been created, we need to move some of the rock tiles to layer 1.  Ultimately you could use a wall to simply create impassable tiles, but we need to move some tiles to Layer 1 to allow us to create a floor on Layer 1 so Link can walk on it.  Without a traversable tile, Link would fall through to Layer 0.  We don't want that.

 


Create a traversable tile Layer 1 for each mini hill, then send it to the back.  If you have done everything correctly, you should have something that looks similar to the image on the left.

Believe it or not, this was the easy part....

 

I will do my best to try and explain how to make this work right with as little confusion as possible.

 

From this point on, you can choose to create your layer transfer entities using the quick method or the advanced method:

For the Quick method, please continue reading

For the Advanced method, click here.

Creating the Transfer (Quick)

we'll just create one side of the formation for now.  Remember that for each ladder that accesses to a bridge, you will need 2 teletransporters and 2 destinations.

 

Make sure that, for every sensor you place and name, SAVE THE PROJECT so the editor will recognize it!!!!  If you don't, you cannot link teletransporters to destination markers!!


Let's make the first set.  First, place the first destination at the top of the ladder.  Double click on it and give it a name.  I called mine "Up_Layer_1", but you can call it whatever you want.  Either way, REMEMBER THE NAME YOU GIVE IT! Entity names cannot have duplicate names, and you will be referencing the name shortly.

Once you name it, set it to "Keep the same direction", set it to Layer 1, and then click OK
(it should look like this).  Don't forget to
save your project.


Next, place a teletransporter.  This does not need a name, so begin editing it.

Set it to Layer 0.  Set its transition to Immediate.  By default, the destination map is the current map, so you don't need to change this, and finally, set the destination to "Up_Layer_1" and click OK and save your project.

Once you have finished this teletransporter, position it UNDER the Up_Layer_1 destination entity.  You should have this:


Now, we'll do the same thing, but for the bottom of the ladder.  Create a destination and name it.  I named this one "Down_Layer_1".  Set it to Layer 0, have it keep the same direction, and then click OK and save your project.  Place this at the bottom of the ladder, like this:


As with the first teletransporter, it does not need a name, so set it to Layer 1, change the transition to Immediate, leave the destination map alone, since it will be the current map, and set the destination to "Down_Layer_1" and click OK and save your project.

Once you have finished, place the teletransporter on top of the Down_Layer_1 destination entity, as seen below:


Finally, to make this all work right, we'll need to place a transparent ladder tile over the ladder.  Remember, if we move Link to a new layer, there must be something underneath of him so he doesn't fall back down to the lower layer.  Also, if we do not place something under him, when he collides with a teletransporter, the game will lock up!  Scroll up to the color palette at the top of the tileset and select the transparent tile in the "Ladder" section.

 


Place this invisible tile down and resize it to match the size of the ladder.  DO NOT account for the walls! You should have a tile that is this size (see the image).  Make sure the invisible tile is on Layer 1, and then finally position it on top of the ladder. 

You could make this tile a dynamic tile if you like (Right-click and select "Convert to dynamic tile), but it is not necessary.  I would only recommend doing this if you think it would be easier to keep track of the invisible tiles, as they are invisible and you may not know (or remember) if you placed one

 

Congratulations!  You have made a bridge!  As you can see in the mini video, Link can walk underneath the bridge, and when he climbs the ladder to the higher level, he can then walk on top of it, and even collide with the walls of the bridge.  Keep in mind that this is a very simple way to switch Link between layers, which means that he cannot carry anything with him, and he cannot charge his spin attack while switching layers.  It is because the game assumes you are switching to a new map every time you touch a teletransporter, even though it is the same map, Link's behavior will still be completely reset.

Creating the Transfer (Advanced)


This method is a bit more advanced, and will require you to edit some of the script files within your quest directory.  The good news is that this method, while a bit more advanced, actually requires less entities to recreate.

You will need (per ladder):

  • 2 sensors
  • 1 transparent ladder tile
  • the "quest_manager.lua" script (right-click to download)
 
First off, for the map creation process, create your map following the exact same steps as outlined on this page. 
Next we need to download the script "quest_manager.lua" (get it here if you have not downloaded it already)
Once you have this file, open up your quest folder, and locate the "\data\scripts" folder. 

Once this file has been added to your scripts folder, go back into Solarus and locate the scripts folder within the game directory tree.  Once you find it, open it by double-clicking on it.

It will now be open on the right side.

You're looking for this specific section of code:






Technically we don't need to change anything at all, but in order to make the sensors work properly,
we need to know the names we should be giving them.  If you look in the code snippet, you will notice two strings, each wrapped in quotes:

"^Up_Layer" and
"
^Down_Layer"

Keep in mind that THIS IS IMPORTANT

If you like, you can name these whatever you want as long as you remember the names you give them, and as long as you remember to never delete the karat ( ^ ) symbol from the beginning of the name!.  You can close "quest_manager.lua" if you like, but remember to save the file if you made any changes to it.  Edit the file at your own risk.  This particular tutorial assumes you only opened the file to check the sensor names!


  Next we need to open up "main.lua".  There is just one more line of code we need to add, and this command will force your game to access the newly added "quest_manager.lua" file.

Look within "main.lua", and you should see, close to the top, a line that reads:

local game_manager = require("scripts/game_manager")

Below this line of code we are going to press Enter twice, adding an empty line.

Once you do that, add the following line of code:

local quest_manager = require("scripts/quest_manager")

Enter it exactly as you see it here, or you can copy / paste it into "main.lua".

You should see this:


We're all done with the code portion of the tutorial, and can get back to the mapping.  Go back into your map and create 2 sensors.

Double-click the first sensor.  Remember back to the two names you saw in "quest_manager.lua"? Well now we're going to use them.

Name this sensor "Up_Layer" and click OK.  Finally place the sensor on Layer 0 and place it one tile below the top edge of the ladder, like you see in the image to the left.


Name this sensor "Down_Layer" and click OK.  Now place the sensor on Layer 1 and place it flush with the bottom edge of the ladder, like you see here.

Keep in mind that now you can simply copy and paste the sensors and as long as they all start with the names "Up_Layer" and "Down_Layer", Solarus will automatically set the hero to the proper layer when he collides with the sensors.

Feel free to place as many pairs of sensors as you need for your maps!


Just like the final step in the simplified method, all that's left is to create a transparent ladder tile using the ladder section of the tileset.  Resize the tile to fit the walkable part of the ladder and move it to Layer 1 as you did before.

 

As you can see, the hero not only moves under the bridge, but over it as well.  What's more is that he can carry objects with him, and charge his sword while walking between layers.

I hope this tutorial was informative and you have a better understanding of how to move Link between layers effortlessly. 

Happy mapping!