Bridge scene that lets you cross tiles with collision

Godot Version



Hi guys,
still big beginner here with no prior coding experience. I hope this is the right category.
I am trying/playing around with a top down 2D level, and have figured out things like player movement, animation and collision, tile sets and how to give them collision, so the player doesn’t walk off into the water.
Now I would like to make a bridge scene, that i can place over tiles with collision and that lets the character pass over, say, a river or a canyon.
I thought this would be simple enough for my level, but I cannot figure it out. I assume it can be done with collision layers and I asked chatgpt (don’t know if that is looked down upon or not) but I couldn’t make much sense of the later code and it didnt seem to work anyway.

extends Area2D

@export var bridge_layer = 2
@onready var collision_shape = $CollisionShape2D

func _ready():
collision_shape.disabled = false

set_collision_layer_bit(bridge_layer, true)	
set_collision_mask_bit(0, false)

func set_collision_layer_bit(bit: int, value: bool):
var layers = collision_layer
if value:
layers |= 1 << bit
layers &= ~(1 << bit)
collision_layer = layers

func set_collision_mask_bit(bit: int, value: bool):
var masks = collision_mask
if value:
masks |= 1 << bit
masks &= ~(1 << bit)
collision_mask = masks

I know I could just make a tileset for the bridge and have a visually identical set of tiles for the background that doesnt have collision, but I would like to have something I can place and change position and even later maybe have an option of building a bridge either in a fixed location or, just imagine, where the player chooses.
Am I in over my head at my level or am I overseeing a simple solution?
Thanks for your help