Create a new scene and use TileMapLayer as the root node.
Create a new scene and use TileMapLayer as the root node.
In the Inspector locate the Tile Set property
In the Inspector locate the Tile Set property
Replace <Empty> with New TileSet
Replace <Empty> with New TileSet
Use the Terrain.png tileset image located in the Terrain folder.
Use the Terrain.png tileset image located in the Terrain folder.
At the bottom of the screen
At the bottom of the screen
Click on the TileSet tab
Click on the TileSet tab
Drag and Drop the Terrrain.png image into the Tiles window.
Drag and Drop the Terrrain.png image into the Tiles window.
Accept the offer to recreate the Tile Atlas
Accept the offer to recreate the Tile Atlas
Most of our tiles will be solid but, those in the top right corner will be special
Most of our tiles will be solid but, those in the top right corner will be special
They will allow the player to pass through them.
They will allow the player to pass through them.
To achieve this we will use two different physics layers on the TileSet.
To achieve this we will use two different physics layers on the TileSet.
Expand the TileSet property
Expand the TileSet property
Under Physics Layer add TWO new Elements
Under Physics Layer add TWO new Elements
The TileSet now has TWO different physics layers
The TileSet now has TWO different physics layers
Each layer will interact with the player differently.
Each layer will interact with the player differently.
Tiles on Collision Layer 2 will be solid ground tiles and we will rename the layer to reflect that.
Tiles on Collision Layer 2 will be solid ground tiles and we will rename the layer to reflect that.
Tiles on Collision Layer 3 will be pass_through tiles and we will rename the layer to reflect that.
Tiles on Collision Layer 3 will be pass_through tiles and we will rename the layer to reflect that.
The player will occupy Layer 1 and we will rename the layer to reflect that.
The player will occupy Layer 1 and we will rename the layer to reflect that.
Click on the numbers to turn layers on and off as shown in the screenshot to the left.
Click on the numbers to turn layers on and off as shown in the screenshot to the left.
EXPLANATION
EXPLANATION
Collision Layer 2 is ON and LOOKING for collision objects on
Collision Layer 2 is ON and LOOKING for collision objects on
Layer 1 (Player)
Layer 1 (Player)
Collision Layer 3 is ON and LOOKING for collision objects on
Collision Layer 3 is ON and LOOKING for collision objects on
Layer 1 (Player)
Layer 1 (Player)
Rename the layers as shown by clicking on the 3 dots and then Edit Layer Names
Rename the layers as shown by clicking on the 3 dots and then Edit Layer Names
Return to the TileSet
Return to the TileSet
Select the Paint tab
Select the Paint tab
Under Paint Properties
Under Paint Properties
Select Physics Layer 0
Select Physics Layer 0
These are our solid ground tiles
These are our solid ground tiles
Here we can adjust the collision polygon for each individual tile!
Here we can adjust the collision polygon for each individual tile!
For our purposes we will simply leave the polygon as a square
For our purposes we will simply leave the polygon as a square
and paint every tile except for our pass_through tiles as shown.
and paint every tile except for our pass_through tiles as shown.
(Paint by clicking on each tile.)
(Paint by clicking on each tile.)
Under Paint Properties
Under Paint Properties
Switch to Physics Layer 1
Switch to Physics Layer 1
Ensure that One Way is ticked
Ensure that One Way is ticked
for each of the pass_through tiles.
for each of the pass_through tiles.
Adjust the collision polygon
Adjust the collision polygon
Paint the pass_through tiles as shown.
Paint the pass_through tiles as shown.
One Way Collision means that the player can collide with the tile from above
One Way Collision means that the player can collide with the tile from above
but NOT from below.
but NOT from below.
This allows the player to jump UP onto the tile from below with no additional code.
This allows the player to jump UP onto the tile from below with no additional code.