How to apply one way collision to a tilemap in godot 4

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Syton

Hello.

I’m working on a 2d platforming game and I’m using a tilemap for the platforms (and many other stuff), I wanted to know if there is a way to define the collision of some of the tiles (or all of the tiles and create a 2nd tilemap) to one way collision using godot 4?

thank you very much for your help

:bust_in_silhouette: Reply From: malaska

Just fumbled through this myself. The solution isn’t super intuitive, but it’s there.
I am in Godot 4.0.2 stable


First, make sure your collision shapes are set up (skip down if you are done with this):

  1. Tileset > Tiles > Paint
  2. Select a Physics Layer
  3. Add the shapes to the one way tiles

*Note: in my case I needed to configure my tileset to have 2 separate physics layers, I use different collision layers for my one-way tiles. This isn’t really necessary on all projects though.

(see what mine look like below)


Collision Settings Per Tile

Once collisions are set up, you need to use the “Select” section of the Tileset editor, select your tiles, then change the Physics Settings.

  1. Go to Tileset > Tiles > Select
  2. Select your tile, or tiles (works with multiple selected)
  3. In the Select section (you should see after selecting tiles, with the heading “Base Tile”) scroll down to Physics
  4. Expand the Physics layer with the collision shape
  5. Expand the Polygon section
  6. In the polygon section you will see the One Way Collision options!
    (See what mine looks like)

*Note again: in my screenshots you will see downward arrows on each collision shape - those will only appear after turning on one-way collision

Hope this helps!

Godot version 4.0.2 stable

Which way is the innitial one Way collision and how do you change it?
I have a wall where I would like to add to One Way Collisions.
One at the top so you cant walk throuhg it while walking upwards and one at the bottom so you cant walk through it while walking downwards.
The one at the bottom is working but for some reason the one at the top is.
I set up two Polygons and turned on One Way for both of them.
I also already played with the “One Way Margin” but that didn’t seem to help… (setting it to 1 and -1 to see if it changes the One Way direction)

Is there any other way to do it or is it really just the “One Way Margin” and I am too stupid to set this up…

Challedy | 2023-06-19 13:28

2 Likes

If its possible to change the direction of a one way tile in a tilemap, it would be great to know. In my isometric tilemap, they are all the opposite way then I would like.

1 Like

Type 2 and paint them again

1 Like

What do you mean “Type 2 and paint them again”?

I’m in the same situation of having a n horizontal ledge from what I would like to be able to fall (so traverse from top to bottom), but not to climb (so not traverse from bottom to top).
One way works only bottom-to-top indeed.
Is there any other way?