Best practice with Tilemap bounds

Godot Version 4.2.1

Hello, with code, what’s the best way to prevent a character to not leave a tilemap area ?

Thanks

Using nodes and scripts, it is very simple to do.
Check the docs on Physics.
Check the docs on TileMaps.

Given we’re talking about TileMaps, you can assign collision to a tilemap by selecting the tilemap you want to add collision to.
image

With the selection tool, select the tile you want to add collision to.

image

image

Give it a shape in the TileMap inspector.

image

Be sure to edit the TileMaps’ layers and maks.

image

You can edit them by clicking on the three dots.

image

And that should be it!
You can now draw tiles around the player to prevent them from leaving.

Here’s a short tutorial that hopefully answers your question if you prefer video:

Thanks a lot i’m looking for an example where character can’t leave the tilemap surface :
image

oh, i know, i’ll create transparent tiles for bounds

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.