The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

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.

Godot version 3.2.1.stable
in Engine by (35 points)
edited by

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

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

1 Answer

+1 vote
Best answer

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...

by (212 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.