godot
godot copied to clipboard
Segment based polygon shapes only get collisions on edges
Godot version: 3 26ff90eae
Issue description: If a polygon shape is built in segment mode, the interior of the shape is empty, only the segments are valid collisions.
Steps to reproduce: Create a PolygonShape2D in segment mode.
Link to minimal example project: shapetest-bug.zip (the one in the center is in segment mode)
Isn't there an option to decide how detection is done? Like, only segments, interior, exterior?
I don't see anything like that on the shape properties, just build mode (solids or segment), polygon(Vector2), disabled and one way options.
PolygonShape needs to work around the issue that the polygon may be concave, while the SAT collision detection supports only convex shapes. For this purpose, there are two build modes:
Solidsuses convex decomposition to split the concave polygon into multiple convex polygonsSegmentsconstructs the polygon's outline out of line segments, as a consequence the shape collides only on its circumference
So the behavior you're observing is intended with Build Mode set to Segments
you can't use a polygon as rigidbody if you set it to segments, should work fine as static though. this is not a bug. This is why the default is Solids and not segments for it.
maybe we should add a warning sign to the shape if we detect the parent is a RigidBody
reopen to remind us to add such warning sign
@eska014 I see, but a body should collide with the internal part/side of the shape?
@reduz the example uses a static body with segments, just to test how a regular rigid can get stuck inside the shape and intersect_ methods can't hit it.
Using raycast2d, I get the same problem as @eon-s - gets stuck inside the tile
@eska014 I see, but a body should collide with the internal part/side of the shape?
yes, segment shapes are like a 0 tick wall, this works for both keeping bodies outside and also inside of the sahpe, it's a feature, not a bug. if you need to be able to exit, but not enter then consider using one_way_collision
Using raycast2d, I get the same problem as @eon-s - gets stuck inside the tile
i have comented in your issue, your case is different, related yo execution order (you are changing raycast direction and checking collision on the same frame, this causes a fake negative)
@MarianoGnu I will give it a try and make a minimal example
@MarianoGnu one way collisions have problems with raycasts too (are not one side for them) #9423
None of these collision issues are tagged for 3 so I guess some will not be fixed for next stable.
We have now entered release freeze for Godot 3.0 and want to focus only on release critical issues for that milestone. Therefore, we're moving this issue to the 3.1 milestone, though a fix may be made available for a 3.0.x maintenance release after it has been tested in the master branch during 3.1 development. If you consider that this issue is critical enough to warrant blocking the 3.0 release until fixed, please comment so that we can assess it more in-depth.
If bodies with segments-based shapes are meant to be taken as "non-solid" or "empty" bodies, then this just need proper documentation.
Behavior remains the same on 4 with the new body types, maybe is a good time to add these details to the rework on physics documentation or CollisionPolygon2D definition.
I don't know if this should be opened on the documentation repository instead.