Environment - acbarker19/Godot-Action-RPG GitHub Wiki

How to Create a Level

  1. Click the + button at the top of the main window
  2. Select 2D Scene in the left menu
  3. Save the scene to the desired folder

How to Create a Collidable Environment

  1. Click on the World node
  2. Add a new StaticBody2D
  3. Add a new CollisionPolygon2D
  4. If desired, turn on grid snapping
  5. Make sure the CollisionPolygon2D node is selected
  6. Click the Create points button in the top menu (Looks like a green square with a + icon)
  7. Create a shape by clicking points and connect the last point to the first one
  8. If you wish to see the collision shapes when playing the game, go to Debug in the window menu and select Visible Collision Shapes

How to Manage When Objects are Behind Other Objects (YSort)

A YSort node will compare the Y position of every child node and display the object that is further down in front.

  1. Select the world node
  2. Select Add Child Node
  3. Select YSort

Make sure objects' base areas are set up for correct YSorting. For example, the player will want to be YSorted using their feet rather than the middle of their body. To do this, you must:

  1. Click the object's Open in Editor button (Looks like movie clapperboard)
  2. Select the Sprite, CollisionShape2D, and other relevant child nodes
  3. Move the selected nodes up or down so the base area is on the scene's origin. With the player example, the player's feet would be over the scene's origin.

How to Create a Repeating Background Using Sprite Nodes

This is a longer method but is the way repeating textures are originally meant to be set up.

  1. Click the World node
  2. Select Add Child Node
  3. Select Sprite
  4. In the right menu, uncheck Offset > Centered
  5. In the right menu, check Region > Enabled
  6. Expand the texture to the desired size using the handles in the editor window, the handles in the TextureRegion tab of the bottom menu, the Transform > Position and Region > Rect values in the right menu
  7. Click the sprite texture file in the bottom left menu
  8. Select the Import tab in the top left menu
  9. Select Flags > Repeat to Enabled and reimport

How to Create a Repeating Background Using TextureRect Nodes

This is a quicker method but possibly has drawbacks due to it being a control node mainly meant for UI.

  1. Click the World node
  2. Select Add Child Node
  3. Select TextureRect
  4. Drag the texture file from the bottom left menu to Texture in the right menu
  5. In the right menu, select Stretch Mode > Tile
  6. Expand the texture to the desired size using the handles in the editor window

How to Add a TileMap

TileMaps are used to quickly draw areas of the background that can be programmatically connected together to make the best-looking image.

  1. Click the World node
  2. Select Add Child Node
  3. Select TileMap
  4. In the right menu, set the correct Cell > Size (This game uses 16 x 16)
  5. Select Tile Set > New TileSet or select an existing TileSet

How to Set Up a TileSet

  1. Click the TileMap node
  2. Click on Tile Set > TileSet
  3. In the bottom TileSet menu, press the Add Texture(s) to TileSet. button (Looks like a box with a +)
  4. Select a tileset image file
  5. In the bottom menu, select New Autotile
  6. Click the Enable snap and show grid button (Looks like a grid with a magnet) and drag across the texture
  7. In the right menu, set Snap Options > Step to the desired size (This game uses 16 x 16), and redraw the snap region to better fit the texture
  8. Click inside the texture to select the region
  9. In the right menu, set Selected Tile > Subtile Size to the desired size (This game uses 16 x 16)
  10. In the right menu, select Autotile Bitmask Mode > 3X3 (minimal)
  11. In the bottom menu, select the Bitmask tab
  12. For each tile in the texture, select what tiles must exist to create that tile. Each tile will be split into a 3x3 grid with the center square in the grid being the selected tile. For example, if the top left tile is being set, the middle grid square must be selected since it is the current tile, and the grid squares to the right, bottom, and bottom right must be selected since there need to be other tiles on those sides to produce the top left tile. For a completed TileSet, click here
  13. Click the TileMap node
  14. Select the desired TileSet in the right menu
  15. Draw the paths in the editor window

How to Set the Icon of a TileSet

  1. Click the TileMap node
  2. Click on Tile Set > TileSet
  3. In the bottom TileSet menu, click the TileSet in the large area
  4. Press the Icon tab
  5. Select the tile that should be the icon

How to Add Collisions to a TileSet

  1. Click the TileMap node
  2. Click on Tile Set > TileSet
  3. In the bottom TileSet menu, click the TileSet in the large area
  4. Press the Collision tab
  5. Select the rectangle or polygon icons based on what shape is needed

Other TileSet Options

The following TileSet options are accessible in the same way as the collision options

  • Occlusion: Automatically create shadows for tiles
  • Navigation: Set up navigation for AI
  • Priority: Set the odds for multiple textures that exist for one type of tile
  • Z Index: Set the height of tiles and how they overlap one another