Help on one-way direction in specific atlas tiles

Version: Godot 4.3

I am making a remake of Link’s Awakening (2.5D top-down) to learn game development, how would I make the one-way so you fall down the ledge instead of going up and can’t return down? (I have tried various methods and I am using specific tiles in an atlas tileset) The one-way direction is locked to face upwards.

Link on a mountain ledge.

extends CharacterBody2D

var current_tile = null
var ledge_direction = Vector2.DOWN # Assume ledges face downwards

func _physics_process(delta):
var input_vector = Vector2.ZERO

# Handle player movement
if Input.is_action_pressed("ui_up"):
    input_vector.y -= 1
elif Input.is_action_pressed("ui_down"):
    input_vector.y += 1
elif Input.is_action_pressed("ui_left"):
    input_vector.x -= 1
elif Input.is_action_pressed("ui_right"):
    input_vector.x += 1

# Check if on a ledge tile
current_tile = get_tile_at_position(global_position)

if current_tile and current_tile.has_meta("one_way"):
    var direction = current_tile.get_meta("one_way")
    if direction == "down":
        if input_vector == Vector2.UP:
            input_vector = Vector2.ZERO  # Block upward movement

# Apply movement
velocity = move_and_slide(input_vector * speed)

Helper function to get the tile under the player

func get_tile_at_position(pos):
var tilemap = $TileMap
var cell = tilemap.world_to_map(pos)
return tilemap.get_cell_data(cell.x, cell.y)

You can create invisible StaticBody2D with a CollisionShape2D and active one way collision, so the character can pass fo them in one direction but will be blocked in the other, you can rotate the StaticBody2D to adjust the side that can pass and the side that will collide.

I’m doing rotation for specific tiles; it only lets me set the OWC boolean and margin settings.