0 votes

Does anybody knows how can I make a single CollisionPolygon2D?
When I put a lot of dots, they divide into several colors, each color is like another collision shape, so each color passes through the one way collision, How can I made a single color CollisionPolygon2D?


in Engine by (153 points)

Those colors are not individual collision shapes so theirs no problem.

1 Answer

+1 vote

The colors are merely indicating how the polygon is triangulated. It's still one collision shape! That your polygon is falling through the floor has nothing to do with this, it is simply the effect of enabling the "One Way Collision"-property. Rotate the polygon by 180 degrees and it will no longer fall through the floor.

by (10,423 points)

but if I rotate the polygon it wil be turned, and I don´t want that, If I make the polygon of 1 color the polygon don´t fall through the floor, but I need more triangulations

but if I rotate the polygon it wil be turned

Only if your first create the polygon and then rotate it.

If I make the polygon of 1 color the polygon don´t fall through the floor

I cannot reproduce this, a simple triangle falls through the floor as well.

I rotated it, and it keeps happening. I do not understand, because this happens to me with a polygon, I can walk up and down the block that has the one way activated, but if I do it with a collisionshape or with a single color in the polygon, this does not happen, I can only walk up, as it should be. It's like with the colors it gets stuck in the middle of the block, like in the second photo, you can move like if there were a second floor

Can you upload your project somewhere and provide a link to it here? Otherwise, I'm afraid I cannot help you as things seem to work differently on my end.

This is not a code problem, this always happens in any project. If you create a kinematic with a polygon collision shape, and you have a block (static body for example) with one way collision activated, If you are on top of the block (as in the first photo), and you fall from the sides of the block, you get stuck (second photo) and when you are stuck, you can walk to the sides, as if it were a second floor of the block. All this does not happen with a collision shape, or a polygon shape of a single color, when you throw yourself by the sides, it just falls, it does not get stuck

i never stated that it was a code problem. I merely asked if you can upload an example project as I cannot reproduce your issue on my end.

haha, So i don´t know how to share, but I tried something, This is an old sample that I have

play the scene with the collision enabled on depurator, and then go to the collision and jump on top of it, and then fall from the sides to the collision and you will get stuck ( and you will get stuck in every color of the polygon)

While I'm not certain, I think you might have stumbled across a bug here, so consider creating an issue over at github. Switching the polygon's build_mode-property from "Solids" to "Segments" seems to fix the issue, but somehow makes the character jittery when pushed into the ground by gravity (which might be another bug actually).

Thanks a lot for your time, I will report the bug

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 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 webmaster@godotengine.org with your username.