I found the reason for the incorrect operation of the logic to hang on a ledge.
Raycast behaves differently with tile map and tile set. The reason is my disposition of district castes.
This is how the raycast behaves with a TileMap:
RayCast2D. is_coulliding() = true
.....|
<-----
.....|
RayCast2D. is_coulliding() = false
(When raycasting inside a collision, it evaluates to false)
.......|
<--- |
.......|
RayCast2D. is_coulliding() = false
.....|
.....| <----
.....|
This is how the raycast behaves with a TileSet:
RayCast2D. is_coulliding() = true
.....|
<-----
.....|
RayCast2D. is_coulliding() = true
(When raycasting inside a collision, it evaluates to true)
.......|
<--- |
...... |
RayCast2D. is_coulliding() = false
.....|
.....| <----
.....|
In my opinion, working with tilemap is not logical!