Area2D with LineShape2d registers nonexistent collisions on scene start

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

I have a scene with instances of two other scenes I’ve made inside of it, my player and a building. The player is built off of a KinematicBody2D, and the building has an Area2D as a child whose shape is a LineShape2D. The player’s shape in no way overlaps with this LineShape2D, but when I run the scene, the Are2D detects that the player as entered it. I’m not sure what I’m missing here.

Edit: I modified the building scene so that the Area2D begins with monitoring set to false, and then after 5 seconds monitoring is enabled. Sure enough, after 5 seconds were up, the Area2D registered every body in the scene having entered it, even though none of them did. Is this just some weird property of LineShape2D? Because its behavior otherwise is exactly what I need, but I don’t know how to avoid this beyond I guess just ignoring bodies that enter it for a split second after the scene runs, and I feel like there should be a more graceful solution.

Are you setting positions in code or are all your `position s set in the editor?

timothybrentwood | 2021-05-10 13:42

All positions are set in the editor. Even at runtime, the player moves with move_and_slide().

Solid_Turner | 2021-05-10 13:48

:bust_in_silhouette: Reply From: albinaask

The line shape does not do what you think it does, it registers everything on one side of the line as colliding and nothing on the other side as colliding, same with planes in 3D, it also extends infinitely far in both directions, so when you add a few you get even weirder behaviours.

Long story short, they are there for very specific occasions and you probably want to avoid using them as much as possible, I personally would suggest using a RectangleShape2D and set it to the sizee of the building the extra performance cost is basically 0, if it’s crucial it’s a line you may play with the width of the shape and set it rather low…