Warning: Undefined array key "HTTP_ACCEPT_LANGUAGE" in /var/www/vhosts/bilgigunlugum.net/httpdocs/index.php on line 43
Godot Game Engine

SDL3 Oyun Programlama ve Godot Oyun Motoru sayfalarımız yayında...

Ana sayfa > Oyun programlama > Godot game engine > Creating physics layer

Creating physics layer

To prevent the player from falling as soon as the game starts, we need to add a physics layer for the tile frames.

To add a physics layer, follow the steps below:

1. While the "TileMapLayer" Node is selected in the "Game" scene, select the "TileSet" option under "TileMap" in the "Inspector" tab, and click the "Add Element" button under "Physics Layers".

2. To select the tiles that we want to have collision properties (the player cannot move when they touch them), while the "TileSet" tabs in the bottom bar and the "Tiles" tabs in the top bar and the "Paint" button are selected, select the "Physics Layer 0" option from the selection box under the "Paint Properties" heading.

3. When we click the tiles shown under the "Base Tiles" heading with the left mouse button, they are painted with transparent blue and gain the Collider (obstacle) feature.

4. To cancel the tile selected as a collider, we can click on the "Clear" option from the menu shown below.

When the "TileMap" tab is selected, the tiles are transferred to the stage, and when the "TileSet" tab is selected, the collision properties of the tiles are determined.

5. Certain parts of the tiles can be selected as colliders. To perform this operation, after setting the collision boundary coordinates for the tile we selected with the mouse in the window shown in the image below, we can click on the tile squares where we want these settings to apply with the left mouse button.

6. Drag and drop the "TileMapLayer" Node to be just below the "Game" Node.

7. Save the scene with Ctrl-S and run the game. The player will not fall down and move with the arrow keys.

However, the game window disappears when it reaches the end. Camera tracking is needed to solve this problem.