RayCast2D ignoring collisions depending other objects position

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MerrMite

My player is using grid based with a tween doing the actual movement of everything.
A raycast2D is used to check for collisions on the destination tile.

I have a building which is a static body with child nodes for a sprite and collision (rectangle)

both the player and building are stored in a YSort Node in the scene.

This setup works most of the time, but certain areas of the map cause 1 of the buildings to let me onto a collision tile. This NOT happening at random.

This even happens across the entire length of the axis. (for example, the building allows me to cross the x-axis of the collision tile no matter what position it is on the y-axis)
These buildings can only be placed in the specific 16x16 grid which should work no matter where it’s placed.
Placing the same object 1 or 2 tiles along the x-axis has it working again perfectly.

working e.g. the building is placed in a position where the far left of the collision object is at x=16.
Player cannot get onto tiles at x=16

bugged e.g. the same building is placed in a position where the far left of the collision object is at x=32.
Player can reach tiles at x=32 where it then becomes stuck within the collision object of the building

:bust_in_silhouette: Reply From: MerrMite

This seemed to have all been down to the scale of the collisionobject2d not being set to 1.
I changed the grid snap to scale the collision rectangle to the same edges as before and this no longer tricks my raycast