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

: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