Area2d scaling shape triggers body_entered/exited at load

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

Hi all, I have been working on a project and noticed that a body which is no where near the area2d is triggering the body_entered and body_exited signals when the scene loads.

The scale is one line of code here:

sightShape.scale = Vector2(sight_range, sight_range)

scaling for this is 6x in my test. The original radius is 32. The body is much farther than 192 pixels away (though a separate issue is the actual scale is much less than this for some reason when viewed with debug on).

After the scene loads, the area2d behaves normally. Though I can see potential cases where this could cause buggy behavior.

I assume that there is definitely an issue with scaling here: removal of the scaling line and this does not occur

:bust_in_silhouette: Reply From: exuin

Yes, it’s a known bug that scaling collision shapes messes with the physics. You should change the extents of the shape instead of scaling them.

Interesting, when I do it this way (using a circle):

	sightShape.shape.radius = int(sight_range * TILESIZE)

I get the same issue

paxmustela | 2021-04-18 18:44

That’s strange. Does the body ever change position?

exuin | 2021-04-18 18:45

Ha! Why yes it does and I completely forgot about it. Thank you

paxmustela | 2021-04-18 18:47