Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CollisionPolygon2D fall through with One Way Collision enabled #25732

Closed
DleanJeans opened this issue Feb 9, 2019 · 7 comments · Fixed by #42574
Closed

CollisionPolygon2D fall through with One Way Collision enabled #25732

DleanJeans opened this issue Feb 9, 2019 · 7 comments · Fixed by #42574

Comments

@DleanJeans
Copy link

Godot version: Godot 3.1 Beta 3

OS/device including version: Windows 10

Issue description:

polygoncollision

Steps to reproduce:
Seems to happen only when the body with polygon is moving upwards

Minimal reproduction project:

OneWayPolygonCollision.zip

@DleanJeans
Copy link
Author

@akien-mga akien-mga reopened this Feb 23, 2019
@reduz
Copy link
Member

reduz commented Feb 23, 2019

Sorry, I quit programming, I'll go open a farm.

@akien-mga akien-mga modified the milestones: 3.1, 3.2 Mar 4, 2019
@DleanJeans
Copy link
Author

DleanJeans commented Mar 14, 2019

This doesn't seem like CollisionPolygon2D exclusive. A RigidBody2D character can go through a rectangle StaticBody2D wall at times. This is more like a universal bug with One Way Collision.

@andrejp88
Copy link

I just ran into this same issue. In my case I have a capsule-shaped KinematicBody2D (player) falling through a segment-shaped StaticBody2D. Out of the following 5 segments, it only occurs with the one marked X:
image

That one is at y=130, and if I remove it and place another identical platform at that coordinate, the player falls through again. So it seems to be tied to the position. If I set its "One Way Collision Margin" to 1.4 or higher, then the player won't fall through but will instead rapidly vibrate up and down by 1 pixel while standing on it, so unfortunately that's not a solution.

(Using 3.1.1 stable)

@njt1982
Copy link
Contributor

njt1982 commented Nov 1, 2019

I've had some luck by manually replicating this:

if (solids) {
//here comes the sun, lalalala
//decompose concave into multiple convex polygons and add them
Vector<Vector<Vector2> > decomp = _decompose_in_convex();
for (int i = 0; i < decomp.size(); i++) {
Ref<ConvexPolygonShape2D> convex = memnew(ConvexPolygonShape2D);
convex->set_points(decomp[i]);
parent->shape_owner_add_shape(owner_id, convex);
}

So.. in my case I have a "terrain" which I was trying to apply ConcavePolygonShape2D and ConvexPolygonShape2D to without success. This terrain is an array of points (defining the heightmap) rendered using draw_polyline.
What I am doing now is looping over all the points from zero to length-1 and creating individual convex triangles for each i, i+1 and a "bottom" vector2.

This seems to have fixed it for mel it's made all my terrain edges "solid".

@akien-mga
Copy link
Member

For the reference, the project in OP no longer reproduces the issue, as it was fixed by cb09abd.

The project in #25732 (comment) still reproduces the issue in the current master branch.

@capnm
Copy link
Contributor

capnm commented Oct 18, 2020

I can confirm #42574 fixes the issue (broken in 3.2.3.stable)
#25732 (comment)
in the 3.2 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants