Is it possible to access StaticBody2D node from a tile? (in Godot 3.0)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wingedadventurer
:warning: Old Version Published before Godot 3 was released.

Hi all. I am making a platformer game and I have made some tiles with OWC (one-way collision) – by adding StaticBody2D node to that tile in tilemap scene, and a CollisionShape2D with OWC turned on as a child of StaticBody2D node.

My game has gravity flipping and I implemented it successfully on everything except one-way tiles which now need to detect OWC in the other direction!

I’ve been trying to access individual tile’s nodes, or adding tile’s nodes to a group before converting it to tileset, but no luck.

Is there a way to gain access to certain tile’s nodes?

If not, what would be a good approach to making one-way tiles that can flip? I’m thinking of creating a duplicate of those tiles which have OWC in the other way, and then making a code that replaces all tiles which have OWC in normal direction with these duplicates.

— Karlo

:bust_in_silhouette: Reply From: pospathos

Use tile_set function in TileMap node to get current tile set. After you get tile set currentily used in your TileMap you can use find_tile_by_name, tile_get_shape_one_way, but one way collision is a mess in Godot, I don’t think that you can change direction of one way collision by default (you can rotate shape but if you search issues on Github you will see that rotation is not working), you must write your on logic for that.