@"Sky Lion" said:
This is tremendously helpful. Thank you so much for taking the time to consider my issue and write a solution in code. I've implemented this with good success!
Awesome! :smile:
However an issue remains: when the obstructing collisions are TileMaps (the borders of a level), this fails, since the returned position for them is (0, 0). I've been trying to find out how to get the global position of a TileMap that's colliding with an Area2D without success. Would you happen to know?
Hmm, well, the reason it is returning (0, 0)
is because it is getting the global position of the node and not the actual collision point. This, unfortunately, means that TileMaps will not work without adjusting, because all of the tiles with collision are part of the TileMap, whose position does not reflect each individual tile.
You might be able to get the exact collision point using a the collide_and_get_contacts
function, as detailed in this Godot Q&A answer. However, this requires knowing the collision shape of the other object, which may not be retrievable from a tilemap.
Another option is to raycast around the edges of the Area2D rectangle, and then adjust according to the raycast results. It would be more performance heavy, but it would work around the issue.